Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid login token. Missing a required claim: aud when accessing AWS Cognito AssumeRoleWithWebIdentity

I've set up the user pool in Cognito and got the JWT token after authenticating the created user via cognito js sdk. And when I try to invoke the assumeRoleWithWebIdentity api it returns an error, below is the sample api call.

https://sts.amazonaws.com/
?Action=AssumeRoleWithWebIdentity
&DurationSeconds=3600
&RoleSessionName=app1
&RoleArn=arn:aws:iam::id:role/_cross_account_role
&WebIdentityToken=jwtAccessToken
&Version=2011-06-15

The api response,

<ErrorResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
<Error>
<Type>Sender</Type>
<Code>InvalidIdentityToken</Code>
<Message>Missing a required claim: aud</Message>
</Error>
<RequestId>c01780d7-3705-11e8-80ef-533aa2d4f58f</RequestId>
</ErrorResponse>

Would be great if I could know the root cause for this issue.

like image 440
Nirojan Selvanathan Avatar asked Apr 03 '18 06:04

Nirojan Selvanathan


People also ask

How do you authenticate with tokens with Cognito?

Authenticating with tokensWhen a user signs into your app, Amazon Cognito verifies the login information. If the login is successful, Amazon Cognito creates a session and returns an ID, access, and refresh token for the authenticated user.

How do I get my AWS Cognito postman access token?

Open the Postman Application (Here is the link to download Postman Application). Go to Authorization tab. From the dropdown select type as OAuth 2.0 and click on Get access token.

How do I get the new access token from refresh token Cognito?

To use the refresh token to get new ID and access tokens with the user pool API, use the AdminInitiateAuth or InitiateAuth API operations. Pass REFRESH_TOKEN_AUTH for the AuthFlow parameter.

How can I decode and verify the signature of an Amazon Cognito JSON Web Token?

To verify the signature of an Amazon Cognito JWT, search for the key with a key ID that matches the key ID of the JWT, then use libraries to decode the token and verify the signature. Be sure to also verify that: The token is not expired.


1 Answers

When the user is autheticated it gives an access token and ID token.

enter image description here

The issue occurs when you try to use the access token instead of the ID token.

like image 192
Nirojan Selvanathan Avatar answered Nov 15 '22 07:11

Nirojan Selvanathan