OAuth2 token endpoint (RFC 6749 Section 3.2). Supports the authorization_code, client_credentials, and refresh_token grant types.
Client authentication. Authenticate with HTTP Basic (Authorization: Basic base64(client_id:client_secret)) or with client_id and client_secret in the request body — not both at once (RFC 6749 Section 2.3.1).
PKCE (RFC 7636). When the authorization request included a code_challenge, the matching code_verifier is required here. A mismatch or a code_verifier for a code issued without a challenge is rejected with invalid_grant. S256 and plain challenge methods are supported.
Refresh tokens. Rotate on every use: a successful refresh_token grant retires the presented token and returns a replacement. Refresh tokens expire 30 days after issuance; rotation restarts that window. The authorization_code grant returns a refresh token only when the client is registered for the refresh_token grant type. The client_credentials grant never returns one (RFC 6749 Section 4.4.3).
Scopes. scope is space-separated per RFC 6749 (comma-separated values are additionally tolerated). Must be a subset of the scopes previously granted (authorization code or refresh token) or registered (client credentials).
Errors follow RFC 6749 Section 5.2: 400 (or 401 for invalid_client) with the standard error codes such as invalid_grant, invalid_client, unauthorized_client, unsupported_grant_type, and invalid_scope.
The OAuth2 grant type.
Must match the redirect URI used in the authorization request. Required for authorization_code).
PKCE code verifier (RFC 7636) Required when the authorization request included a code_challenge.
- Mock serverhttps://cafe.redocly.com/_mock/openapi/cafe/oauth2/token
- Live server.https://api.cafe.redocly.com/oauth2/token
curl -i -X POST \
https://cafe.redocly.com/_mock/openapi/cafe/oauth2/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d grant_type=client_credentials \
-d client_id=client_1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d \
-d client_secret=YOUR_CLIENT_SECRET \
-d 'scope=menu:read orders:read'Token issued successfully. The response is not cacheable (it is served with Cache-Control set to no-store).
Refresh token, returned for the authorization_code grant when the client is registered for the refresh_token grant type, and on every refresh (tokens rotate on use). Never returned for the client_credentials grant (RFC 6749 Section 4.4.3).
{ "access_token": "string", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "string", "scope": "menu:read orders:read" }