I'm very new to AWS and I've been struggling with authentication. I used the code from this git for authenticating a user and it worked, but when I try to initialize dynamodb, I receive this error:
"NotAuthorizedException: Missing credentials in config" with the message "Invalid login token. Issuer doesn't match providerName".
This is the code I used to update my credentials after it has been authenticated.
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:...',
Logins: {
'cognito-idp.us-east-1.amazonaws.com/us-east-1:...': result.getIdToken().getJwtToken()
}
});
//CONNECT TO DB
var db = new AWS.DynamoDB({region: 'us-east-1'});
Any help would be appreciated. Thanks!
Hi,
Your implementation looks ok, but I have a concern on the key you have used in the _Logins_ map. The second part of the key, which start with _us-east-1_, should be your user pool id. Pool id's are of the format _us-east-1_xxxxxxxxx_, where _xxxxxxxxx_ are a set of alpha-numeric characters that are unique to your user pool.
Can you please check if the key you have used is of the form _cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxxxxxx_ ?
Thanks,
Mahesh
Wow, thank you so much. Such a simple fix. I was using my Identity Pool ID instead of the user pool ID for that portion. Thanks again!
Most helpful comment
Hi,
Your implementation looks ok, but I have a concern on the key you have used in the _Logins_ map. The second part of the key, which start with _us-east-1_, should be your user pool id. Pool id's are of the format _us-east-1_xxxxxxxxx_, where _xxxxxxxxx_ are a set of alpha-numeric characters that are unique to your user pool.
Can you please check if the key you have used is of the form _cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxxxxxx_ ?
Thanks,
Mahesh