Exchange a grant for an access token
Body: application/x-www-form-urlencoded or JSON. Client auth: Authorization: Basic base64(client_id:client_secret), or client_id and client_secret in the body. Clients: apibee-client / apibee-secret (confidential), apibee-public (public, no secret). Users: apibee / password123, jane / jane123.
grant_type values: client_credentials: optional scope; confidential client only; no refresh token. password: username, password, optional scope. authorization_code: code, redirect_uri (if one was sent to /authorize), code_verifier (if PKCE was used). refresh_token: refresh_token. Refresh tokens rotate: each use returns a new one and the old one stops working. Using a spent refresh token again revokes every token from the same grant (reuse detection, RFC 9700). Access tokens expire after 3600 seconds.
Request body
Optional. application/x-www-form-urlencoded. Standard OAuth2 token request (JSON with the same fields also works).
grant_type=client_credentials&client_id=apibee-client&client_secret=apibee-secret&scope=readResponses
- 200
- access_token, token_type, expires_in, refresh_token (not for client_credentials) and scope.
- 400
- invalid_request, invalid_grant, invalid_scope, unauthorized_client or unsupported_grant_type.
- 401
- invalid_client: unknown client or wrong secret.
Example
curl -X POST "https://api.testingapis.com/api/auth/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'grant_type=client_credentials&client_id=apibee-client&client_secret=apibee-secret&scope=read' \
-H "X-TestingApis-Key: YOUR_API_KEY"Cache-Control: no-store
{
"access_token": "oat_b10d78524a730b6c2a480d434ca733a91fc37a81",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "read"
}Sign in to see the details
The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.