Amazon-cognito-identity-js: "Invalid login token. Missing a required claim: aud"

Created on 27 Apr 2016  路  4Comments  路  Source: amazon-archives/amazon-cognito-identity-js

Hi,

I managed to make a successful authentication and I am trying to access my Lambda function. The function is allowed to get by specific role I gave to my authenticated users.
When I tried just to access it I got a message that my role for unauthenticated users cannot invoke that function, so I figured I'm just not using the token I just got for the user.
When I'm trying to apply the user's credentials in the config, I get the following message:
"Invalid login token. Missing a required claim: aud".

This is what I do:

AWS.config.credentials = new AWS.CognitoIdentityCredentials({
            IdentityPoolId: 'us-east-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
                        Logins: {
                'cognito-idp.us-east-1.amazonaws.com/us-east-1_XXXXXXXXX': result.getAccessToken().getJwtToken(),
            }
        });

                AWS.config.credentials.get(function(err){
            // Here I get the error message.
        });

Any help would be appreciated,

Thank you!
Guy.

Most helpful comment

You should use getIdToken, not getAccessToken. See #7

All 4 comments

You should use getIdToken, not getAccessToken. See #7

Oh right! Thanks, lusentis. It works.

lusentis; Thanks a million. I was googling for the last 4-7 hours. Thanks alot.

Please fix the documentation

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnf picture johnf  路  3Comments

magnattic picture magnattic  路  5Comments

tranan89 picture tranan89  路  5Comments

RashmiPandey picture RashmiPandey  路  4Comments

ZwaarContrast picture ZwaarContrast  路  4Comments