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
gefragt vor einem Jahr1194 Aufrufe
1 Antwort
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
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen