'Requesting USERINFO from amazoncognito.com request using ID_TOKEN

After performing an .....amazoncognito.com/login?.... via the hosted web UI, I am correctly redirected to the callback URL with a query param "id_token" that I can use to access my API Gateway endpoints via x-api-key.

I am wanting to use the ID token to get the Cognito user info associated with that token (for verifying in my API that the token will allow for access to data that should only be accessed by that user).

How can I get the Cognito User ID, email etc? the ....amazoncognito.com/ouath2/userinfo seems like what i need but don't know how to correctly use that endpoint with the ID_token I have.



Solution 1:[1]

The ID token is a JWT token which encodes JSON in in the payload containing user data. The ID token needs to be decoded to access the desired user data.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lehel the Mage