Home > Enterprise >  AWS cognito how to forgot password with lambda
AWS cognito how to forgot password with lambda

Time:04-16

I need implement logic for forgot password with aws lambda. I have cognito user pool with users and i need implement lambda for forgot password. How can i do it? Thanks in advance.

CodePudding user response:

You can use AWS SDK to invoke the Cognito-forgot password from LAMBDA. you can refer to this documentation. You may have to provide the User pool Client and Username of the user along with the request.

Note: Your Lambda execution policy should have cognito-idp:ForgotPassword

Here is the Documentation for implementing with Nodejs.

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

export.handler = async (event) => {

    const params = {
        ClientId: 'USER POOL CLIENT ID',
        Username: 'USERNAME'
    }
    const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider();

    const response = cognitoidentityserviceprovider.forgotPassword(params).promise();

    return response;
}
  • Related