1

Using AWS Cognito user pool, I want to register/change the password. But function change password not working

This my code:

 AmazonCognitoIdentityProviderClient provider = new AmazonCognitoIdentityProviderClient(
         new Amazon.Runtime.AnonymousAWSCredentials(), _region);

        CognitoUserPool userPool = new(
               _configuration["AWS:Cognito:UserPoolId"],
               _configuration["AWS:Cognito:ClientId"],
               provider);

        CognitoUser user = new(email,
            _configuration["AWS:Cognito:ClientId"],
            userPool,
            provider,
            _configuration["AWS:Cognito:SecretHash"]);

        var authRequest = new InitiateSrpAuthRequest()
        {
            Password = oldPassword
        };
        try
        {
            var authResponse = await user.StartWithSrpAuthAsync(authRequest);
            await user.RespondToNewPasswordRequiredAsync(new RespondToNewPasswordRequiredRequest
            {
                SessionID = authResponse.SessionID,
                NewPassword = newPassword
            });
        }
        catch (Exception ex )
        {
            throw ex;
        }

Currently, SessionID is null and my function response "Missing required parameter Session"

Anyone could help me. Thanks Link throw exception

Love Bum
  • 11
  • 2

0 Answers0