Skip to content

OAuth2 API Endpoints

AWS Cognito exposes standard OAuth2 and OIDC endpoints for authentication, token exchange, and token verification. All endpoints are accessed over HTTPS.

Note: This document is in progress while Cognito integration is being completed. Confirm endpoint behavior against the live system.

https://<partition>-<infrastructure>.auth.<region>.amazoncognito.com

The <partition>-<infrastructure> string is available as CloudFormation export <infrastructure>-<partition>-API-UserPoolDomain.

Authorization Endpoint — /oauth2/authorize

Section titled “Authorization Endpoint — /oauth2/authorize”

Initiates user sign-in. The browser is redirected here.

ParameterDescription
response_typecode (Authorization Code), token (Implicit)
client_idApp Client ID
redirect_uriRegistered callback URL
scopeSpace-separated scopes: openid profile email ...
stateAnti-CSRF opaque value
code_challenge(PKCE) Code challenge derived from verifier
code_challenge_method(PKCE) S256

Exchange authorization code for tokens, or refresh using a refresh token.

Authorization Code Grant:

ParameterValue
grant_typeauthorization_code
codeAuthorization code from /oauth2/authorize
client_idApp Client ID
redirect_uriSame URI used in authorization request
code_verifier(PKCE) Plain text secret

Refresh Token Grant:

ParameterValue
grant_typerefresh_token
refresh_tokenRefresh token
client_idApp Client ID

Authentication: Client ID + secret via Authorization: Basic <base64(client_id:secret)> header.

Returns authenticated user claims. Requires Authorization: Bearer <access_token>.

Returns public keys for verifying JWT signatures. URL format:

https://cognito-idp.<region>.amazonaws.com/<user-pool-id>/.well-known/jwks.json

Cache these keys; refresh only when a token cannot be verified with the cached keyset.

Ends the Cognito session and redirects the user.

ParameterDescription
client_idApp Client ID
logout_uriRegistered sign-out URL to redirect to post-logout

OIDC Discovery Endpoint — /.well-known/openid-configuration

Section titled “OIDC Discovery Endpoint — /.well-known/openid-configuration”

Returns OIDC metadata including all endpoint URLs, supported scopes, and JWKS URI. Useful for automatic client library configuration:

https://<cognito-domain>/.well-known/openid-configuration

Revokes a refresh token.

ParameterDescription
tokenRefresh token to revoke
client_idApp Client ID
client_secretClient secret (if applicable)

M2M Authentication (Client Credentials Flow)

Section titled “M2M Authentication (Client Credentials Flow)”

Backend services use the Token endpoint with client_credentials grant:

POST /oauth2/token
Authorization: Basic <base64(client_id:client_secret)>
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=<scopes>

Successful Response:

{
"access_token": "...",
"expires_in": 3600,
"token_type": "Bearer"
}

Amplify requires only two values for Cognito integration:

  • User Pool ID: <infrastructure>-<partition>-API-UserPoolId (CloudFormation export)
  • App Client ID: <infrastructure>-<partition>-API-WebClientId (CloudFormation export)