Amazon-cognito-identity-js: AWS authenticateUser failing

Created on 30 May 2016  路  5Comments  路  Source: amazon-archives/amazon-cognito-identity-js

Hi, I am following the steps on the guide and I have succesfully SignedUp users via js client, however when I try to authenticate my signed and confirmed users I get: Error: Incorrect username or password. I have created new users and verified that username and password is correct. Is there any other event that could trigger this error?

Thanks for your help.

Code:
Note: userPool is already created with app data and works for registration, username and password are retrieved from a form and were verified with console.log
var authenticationData = {
Username : username,
Password : password,
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var userData = {
Username : username,
Pool : userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result);
// console.log('access token + ' + result.getAccessToken().getJwtToken());
},

    onFailure: function(err) {
        console.log(err);
        alert(err);
    }

});  

Most helpful comment

Already solved :/ got a wrong poolId not sure why signUp was working fine.

All 5 comments

Already solved :/ got a wrong poolId not sure why signUp was working fine.

Can confirm that as of today, an incorrect UserPoolId does not prevent signUp(), but does prevent authenticateUser()

I can confirm that as well. I also tried creating a user in a ramdom/made up userpoolid which we do not own and was able to create the user. Why would this be possible?

I really wonder how this issue can be closed.
Just fell over this in the last few days, where I CAN create a user and confirm it, but not authenticate.
At least the error message should not be 'x-amzn-ErrorMessage:Incorrect username or password.'

Yes, this one just bit me yesterday/today as well. Seems odd that you can do signUp() at all. Would think some kind of connection error (maybe 404) would be more appropriate if the UserPoolId value was incorrect for both signUp as well as authenticateUser().

Was this page helpful?
0 / 5 - 0 ratings