Identity and Access Management

An Amazon Cognito authorization-code flow returns a code, but token exchange fails with invalid_grant; the code is fresh, unused, and its PKCE verifier is correct. The authorization request used a callback URI ending in /callback, while the token request uses /callback/; what should the developer change?

Show the answer

Correct answerA. Use the identical redirect_uri in both requests

AWhy this is right: The redirect_uri in the token exchange must match the value used in the authorization request.

BWhy not this: Implicit grant does not repair an authorization-code exchange and changes the authentication flow.

CWhy not this: Allowlisting both URIs does not resolve a mismatch between requests in the same authorization-code flow.

DWhy not this: Identity pools issue AWS credentials, not OAuth tokens in exchange for authorization codes.

The token request's redirect_uri must match the URI used to obtain the authorization code. Allowlisting both callback URIs does not make them interchangeable during a single authorization-code exchange.