Tuesday, 25 September 2018

cognito and aws cli to reset password

If you have the error:

An error occurred (InvalidParameterException) when calling the AdminRespondToAuthChallenge operation: Invalid attributes given, name is missing

aws cognito-idp admin-initiate-auth --user-pool-id xxxx --client-id xxxxxxxxx --auth-flow ADMIN_NO_SRP_AUTH --auth-parameters USERNAME=xxxx,PASSWORD=xxxxx --region=xxxxx

then

aws cognito-idp admin-respond-to-auth-challenge --region=xxxxxx --user-pool-id xxxxxxx --client-id xxxxxxx --challenge-name NEW_PASSWORD_REQUIRED --challenge-responses file://auth.json --session "zxxxxxx"

create a file auth.json with content:

{
 "userAttributes.name": "xxxxx",
 "userAttributes.family_name": "xxxxx",
 "userAttributes.email": "xxxx@xxxxx",
 "NEW_PASSWORD": "xxxxx",
 "USERNAME": "xxxxx"
}