Amazon Cognito user invite

0

Hi Guys, I am trying to send invite email to a user with a link that user can click and enter password so that I can create user. Do I need to use Lambda for this? Any documentation will be helpful

ozy
已提問 1 年前檢視次數 1199 次
1 個回答
0

Hi,

You can create a new user the specified user pool through the Amazon Cognito API's. Refer here for the API details : https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html.

If you are using the AWS SDK, then the guidance on how to do this is here: (This is JS, you can browse for the SDK for the programming language of your choice) https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html.

For Lambda, as you've mentioned above, if you want to create an user - then the sample is as provided below,

const AWS = require('aws-sdk');

const userPoolId = 'YOUR_USER_POOL_ID';
const clientId = 'YOUR_APP_CLIENT_ID';
const region = 'YOUR_REGION';

const cognito = new AWS.CognitoIdentityServiceProvider({ region });

const params = {
  UserPoolId: userPoolId,
  Username: 'NEW_USER_USERNAME',
  DesiredDeliveryMediums: ['EMAIL'],
  UserAttributes: [
    {
      Name: 'email',
      Value: 'NEW_USER_EMAIL',
    },
    {
      Name: 'name',
      Value: 'NEW_USER_NAME',
    },
    {
      Name: 'custom_attribute',
      Value: 'CUSTOM_VALUE',
    },
  ],
  TemporaryPassword: 'TEMP_PASSWORD',
  MessageAction: 'SUPPRESS',
};

cognito.adminCreateUser(params, (err, data) => {
  if (err) {
    console.log(err, err.stack);
  } else {
    console.log(data);
  }
});

Please refer https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html and create the user pools and the necessary user attribute settings

Hope this helps

AWS
Arun
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南