Skill 2.1.2

Secure applications by using bearer tokens

Key Concepts

Cognito user pools issue an ID token (who the user is, for the client), an access token (what the user may do, with scopes, for APIs) and a refresh token (to obtain new tokens). Clients send the token in the Authorization header, and APIs verify its signature against the issuer's public keys (JWKS), its expiry, issuer and audience before trusting its claims.

API Gateway can validate tokens for you with a Cognito user pool authorizer (REST APIs), a JWT authorizer (HTTP APIs) or a Lambda authorizer for custom logic. Because anyone holding a bearer token can use it, tokens must only travel over HTTPS, should be short-lived and should never be logged.