Issue an OAuth 2.0 access token
POST/oauth2/token
Exchanges an authorization code, refresh token, or client credentials for an access token
(and optionally a refresh token and ID token for OpenID Connect clients).
The grant_type parameter selects the exchange:
authorization_code— exchanges a code received at the authorization endpoint; requirescodeandredirect_uri, andcode_verifierfor PKCE clients.refresh_token— exchanges a refresh token for a new access token; requiresrefresh_token.client_credentials— issues a token for the client itself without end-user involvement; does not requirecodeorrefresh_token.urn:ietf:params:oauth:grant-type:jwt-bearer(RFC 7523) — exchanges a JWT assertion for an access token; requiresassertion.
Client authentication is performed using one of the configured methods:
HTTP Basic (client_id and client_secret in the Authorization header),
POST body parameters (client_id + client_secret), or JWT client assertions
(client_assertion + client_assertion_type).
Refer to the introduction section for details on how to configure this use case.
Request
Header Parameters
HTTP Basic authentication header for confidential client authentication. Credentials are client_id:client_secret Base64-encoded.
- application/x-www-form-urlencoded
Body
The grant type. One of authorization_code, refresh_token, client_credentials, or urn:ietf:params:oauth:grant-type:jwt-bearer.
The authorization code received from the authorization endpoint. Required for the authorization_code grant.
Must exactly match the redirect_uri used in the original authorization request. Required for the authorization_code grant only if redirect_uri was included in the original authorization request (RFC 6749 Section 4.1.3).
The client identifier. Required for public clients; optional for confidential clients authenticating via the Authorization header.
The client secret. POST body credential transmission is NOT RECOMMENDED by RFC 6749 Section 2.3.1; HTTP Basic authentication via the Authorization header is preferred. Only for clients that cannot use HTTP Basic authentication.
The refresh token previously issued by the token endpoint. Required for the refresh_token grant.
Space-delimited list of requested scopes. Optional for most grants. For the refresh_token grant, this parameter is ignored: nevisAuth always issues the new token with the same scopes as the original grant.
(PKCE) The original high-entropy random string whose hash was sent as code_challenge at the authorization endpoint. Required for clients that used PKCE.
(JWT Bearer grant) The JWT assertion representing the subject on whose behalf the token is requested. Required for the urn:ietf:params:oauth:grant-type:jwt-bearer grant.
JWT used to authenticate the client itself. Used together with client_assertion_type as an alternative to client_secret.
Indicates the type of the client_assertion. Must be urn:ietf:params:oauth:client-assertion-type:jwt-bearer when using JWT client authentication.
URI of the target resource or service the access token is intended for (RFC 8707). When present, the server derives the token audience from the resource metadata. May be repeated to request access to multiple resources.
Responses
- 200
- 400
- 401
Token issued successfully
- application/json
- Schema
- Example (from schema)
Schema
The issued access token. Clients use this to access protected resources.
The type of the token. Always Bearer for nevisAuth.
Lifetime of the access token in seconds.
Refresh token issued alongside the access token. Only present when the offline_access scope was granted and the grant type supports it.
Space-delimited list of scopes actually granted. Omitted if identical to the requested scope.
Signed JWT identity token (OpenID Connect). Only present when openid scope was requested.
{
"access_token": "eyJhbGciOiJSUzI1NiJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "string",
"scope": "string",
"id_token": "string"
}
Invalid request or unsupported grant type
- application/json
- Schema
- Example (from schema)
Schema
A single ASCII error code identifying the error. Common values include invalid_request, invalid_client, invalid_grant, unauthorized_client, unsupported_grant_type, and invalid_scope.
Human-readable ASCII text providing additional information about the error. Intended to assist the client developer and is not meant to be shown to the end user.
A URI identifying a human-readable web page with information about the error.
{
"error": "invalid_grant",
"error_description": "The authorization code has expired.",
"error_uri": "https://example.com/errors/invalid_grant"
}
Client authentication failed
- application/json
- Schema
- Example (from schema)
Schema
A single ASCII error code identifying the error. Common values include invalid_request, invalid_client, invalid_grant, unauthorized_client, unsupported_grant_type, and invalid_scope.
Human-readable ASCII text providing additional information about the error. Intended to assist the client developer and is not meant to be shown to the end user.
A URI identifying a human-readable web page with information about the error.
{
"error": "invalid_grant",
"error_description": "The authorization code has expired.",
"error_uri": "https://example.com/errors/invalid_grant"
}