Exchange or refresh an access token
const url = 'https://localhost:8080/api/v1/auth/token';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"grant_type":"urn:ietf:params:oauth:grant-type:token-exchange","refresh_token":"example","subject_token":"example","subject_token_type":"urn:ietf:params:oauth:token-type:access_token"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://localhost:8080/api/v1/auth/token \ --header 'Content-Type: application/json' \ --data '{ "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "refresh_token": "example", "subject_token": "example", "subject_token_type": "urn:ietf:params:oauth:token-type:access_token" }'Issue an enriched access token (and rotated refresh token) via OAuth 2.0 Token Exchange (RFC 8693) or refresh-token grant; also mounted at /api/v1/auth/token-exchange for backward compatibility
Request Body
Section titled “Request Body ”Token request
object
Required for the refresh_token grant
Required for the token-exchange grant
Token-exchange grant; access_token only
Responses
Section titled “ Responses ”Token response
An OAuth token response, returned by both the exchange and refresh grants
object
Access token lifetime in seconds
Refresh token lifetime in seconds
Example generated
{ "access_token": "example", "expires_in": 1, "issued_token_type": "example", "refresh_expires_in": 1, "refresh_token": "example", "scope": "example", "token_type": "example"}Invalid request
Error body returned across the auth endpoints; the message is human-readable and not a stable identifier
object
Example
{ "error": "Unauthorized", "error_description": "Invalid token"}Invalid or expired token
Error body returned across the auth endpoints; the message is human-readable and not a stable identifier
object
Example
{ "error": "Unauthorized", "error_description": "Invalid token"}Internal server error
Error body returned across the auth endpoints; the message is human-readable and not a stable identifier
object
Example
{ "error": "Unauthorized", "error_description": "Invalid token"}