forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JS v3 added Cognito->AdminCreateUser sample.
- Loading branch information
1 parent
1d230ac
commit 3470538
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
ABOUT THIS NODE.JS EXAMPLE: This example works with AWS SDK for JavaScript version 3 (v3) | ||
Purpose: | ||
admin-create-user.js demonstrates how to create an user from Cognito SDK. | ||
*/ | ||
|
||
//snippet-sourcedescription:[admin-create-user.js demonstrates demonstrates how to create an user from Cognito SDK.] | ||
//snippet-service:[cognito] | ||
//snippet-keyword:[JavaScript] | ||
//snippet-sourcesyntax:[javascript] | ||
//snippet-keyword:[Code Sample] | ||
//snippet-keyword:[Amazon Cognito] | ||
//snippet-sourcetype:[full-example] | ||
//snippet-sourcedate:[2021-09-28] | ||
//snippet-sourceauthor:[zachjonesnoel] | ||
|
||
// ABOUT THIS NODE.JS SAMPLE: This sample is part of the SDK for JavaScript Developer Guide topic at | ||
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#adminCreateUser-property | ||
|
||
// snippet-start:[ses.JavaScript.filters.admin-create-user] | ||
// Load the AWS SDK for Node.js. | ||
var AWS = require('aws-sdk'); | ||
// Set the AWS Region. | ||
AWS.config.update({ region: 'REGION' }); | ||
// Initialize CogntioIdentityServiceProvider SDK. | ||
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider(); | ||
var params = { | ||
UserPoolId: "UserPoolID", | ||
Username: "[email protected]", | ||
DesiredDeliveryMediums: [ | ||
"EMAIL" | ||
], | ||
MessageAction: "RESEND", | ||
TemporaryPassword: "Password@123", | ||
UserAttributes: [ | ||
{ | ||
Name: "email", | ||
Value: "[email protected]" | ||
} | ||
] | ||
} | ||
var response = await cognitoidentityserviceprovider.adminCreateUser(params).promise() | ||
console.log(JSON.stringify(response, null, 2)) | ||
// snippet-end:[ses.JavaScript.filters.admin-create-user] |