Process Token Request
This API parses request parameters of an authorization request and returns necessary data for the authorization server implementation to process the authorization request further.
Documentation Index
Fetch the complete documentation index at: https://developers.authlete.com/llms.txt
Use this file to discover all available pages before exploring further.
Full description
Full description
/auth/token API.
The value of parameters is the entire entity body (which is formatted in application/x-www-form-urlencoded)
of the token request.
In addition, if the token endpoint of the authorization server implementation supports basic authentication
as a means of client authentication,
the client credentials must be extracted from Authorization header and they must be passed as
clientId request parameter and clientSecret request parameter to Authlete’s /auth/token API.
The following code snippet is an example in JAX-RS showing how to extract request parameters from
the token request and client credentials from Authorization header./auth/token API has some parameters. Among them, it is action parameter that
the service implementation should check first because it denotes the next action that the authorization
server implementation should take. According to the value of action, the authorization server
implementation must take the steps described below.INTERNAL_SERVER_ERROR
When the value ofaction is INTERNAL_SERVER_ERROR, it means that the request from the authorization
server implementation was wrong or that an error occurred in Authlete.
In either case, from the viewpoint of the client application, it is an error on the server side.
Therefore, the service implementation should generate a response to the client application with
HTTP status of “500 Internal Server Error”. Authlete recommends application/json as the content
type although OAuth 2.0 specification does not mention the format of the error response when the
redirect URI is not usable.
The value of responseContent is a JSON string which describes the error, so it can be
used as the entity body of the response.The following illustrates the response which the service implementation should generate and return to the client application.
INVALID_CLIENT
When the value ofaction is INVALID_CLIENT, it means that authentication of the client failed.
In this case, the HTTP status of the response to the client application is either “400 Bad Request”
or “401 Unauthorized”. This requirement comes from RFC 6749, 5.2. Error Response.
The description about invalid_client shown below is an excerpt from RFC 6749.Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method). The authorization server MAY return an HTTP 401 (Unauthorized) status code to indicate which HTTP authentication schemes are supported. If the client attempted to authenticate via the
Authorization request header field, the authorization server MUST respond with an HTTP
401 (Unauthorized) status code and include the WWW-Authenticate response header field matching
the authentication scheme used by the client.In either case, the value of
responseContent is a JSON string which can be used as the entity
body of the response to the client application.The following illustrate responses which the service implementation must generate and return to the client application.
BAD_REQUEST
When the value ofaction is BAD_REQUEST, it means that the request from the client application
is invalid.
A response with HTTP status of “400 Bad Request” must be returned to the client application and
the content type must be application/json.
The value of responseContent is a JSON string which describes the error, so it can be used as
the entity body of the response.The following illustrates the response which the service implementation should generate and return
to the client application.PASSWORD
When the value of"action" is "PASSWORD", it means that
the request from the client application is valid and grant_type
is "password". That is, the flow is
“Resource Owner
Password Credentials”.
In this case, {@link #getUsername()} returns the value of "username"
request parameter and {@link #getPassword()} returns the value of {@code
“password”} request parameter which were contained in the token request
from the client application. The service implementation must validate the
credentials of the resource owner (= end-user) and take either of the
actions below according to the validation result.- When the credentials are valid, call Authlete’s /auth/token/issue} API to generate an access token for the client
application. The API requires
"ticket"request parameter and"subject"request parameter. Use the value returned from {@link #getTicket()} method as the value for"ticket"parameter. - The response from
/auth/token/issueAPI ({@link TokenIssueResponse}) contains data (an access token and others) which should be returned to the client application. Use the data to generate a response to the client application. - When the credentials are invalid, call Authlete’s {@code
/auth/token/fail} API with
reason={@link TokenFailRequest.Reason#INVALID_RESOURCE_OWNER_CREDENTIALS INVALID_RESOURCE_OWNER_CREDENTIALS} to generate an error response for the client application. The API requires"ticket"request parameter. Use the value returned from {@link #getTicket()} method as the value for"ticket"parameter. - The response from
/auth/token/failAPI ({@link TokenFailResponse}) contains error information which should be returned to the client application. Use it to generate a response to the client application.
OK
When the value ofaction is OK, it means that the request from the client application is valid
and an access token, and optionally an ID token, is ready to be issued.
The HTTP status of the response returned to the client application must be “200 OK” and the content
type must be application/json.
The value of responseContent is a JSON string which contains an access token (and optionally
an ID token), so it can be used as the entity body of the response.The following illustrates the response which the service implementation must generate and return to the client application.
TOKEN_EXCHANGE (Authlete 2.3 onwards)
When the value of"action" is "TOKEN_EXCHANGE", it means
that the request from the client application is a valid token exchange
request (cf. RFC
8693 OAuth 2.0 Token Exchange) and that the request has already passed
the following validation steps.- Confirm that the value of the
requested_token_typerequest parameter is one of the registered token type identifiers if the request parameter is given and its value is not empty. - Confirm that the
subject_tokenrequest parameter is given and its value is not empty. - Confirm that the
subject_token_typerequest parameter is given and its value is one of the registered token type identifiers. - Confirm that the
actor_token_typerequest parameter is given and its value is one of the registered token type identifiers if theactor_tokenrequest parameter is given and its value is not empty. - Confirm that the
actor_token_typerequest parameter is not given or its value is empty when theactor_tokenrequest parameter is not given or its value is empty. Furthermore, Authlete performs additional validation on the tokens specified by thesubject_tokenrequest parameter and theactor_tokenrequest parameter according to their respective token types as shown below.
Token Validation Steps
*Token Type:urn:ietf:params:oauth:token-type:jwt*- Confirm that the format conforms to the JWT specification [RFC 7519][https://www.rfc-editor.org/rfc/rfc7519.html].
- Check if the JWT is encrypted and if it is encrypted, then (a) reject
the token exchange request when the {@link
Service#isTokenExchangeEncryptedJwtRejected()
tokenExchangeEncryptedJwtRejected} flag of the service is
trueor (b) skip remaining validation steps when the flag isfalse. Note that Authlete does not verify an encrypted JWT because there is no standard way to obtain the key to decrypt the JWT with. This means that you must verify an encrypted JWT by yourself when one is used as an input token with the token type { @code “urn:ietf:params:oauth:token-type:jwt” }. - Confirm that the current time has not reached the time indicated by
the
expclaim if the JWT contains the claim. - Confirm that the current time is equal to or after the time indicated
by the
iatclaim if the JWT contains the claim. 5.Confirm that the current time is equal to or after the time indicated by thenbfclaim if the JWT contains the claim. - Check if the JWT is signed and if it is not signed, then (a) reject
the token exchange request when the {@link
Service#isTokenExchangeUnsignedJwtRejected()
tokenExchangeUnsignedJwtRejected} flag of the service is
trueor (b) finish validation on the input token. Note that Authlete does not verify the signature of the JWT because there is no standard way to obtain the key to verify the signature of a JWT with. This means that you must verify the signature by yourself when a signed JWT is used as an input token with the token type"urn:ietf:params:oauth:token-type:jwt". *Token Type:urn:ietf:params:oauth:token-type:access_token* - Confirm that the token is an access token that has been issued by
the Authlete server of your service. This implies that access
tokens issued by other systems cannot be used as a subject token
or an actor token with the token type
urn:ietf:params:oauth:token-type:access_token. - Confirm that the access token has not expired.
- Confirm that the access token belongs to the service.
*Token Type:
urn:ietf:params:oauth:token-type:refresh_token* - Confirm that the token is a refresh token that has been issued by
the Authlete server of your service. This implies that refresh
tokens issued by other systems cannot be used as a subject token
or an actor token with the token type
urn:ietf:params:oauth:token-type:refresh_token. - Confirm that the refresh token has not expired.
- Confirm that the refresh token belongs to the service.
*Token Type:
urn:ietf:params:oauth:token-type:id_token* - Confirm that the format conforms to the JWT specification (RFC 7519).
- Check if the ID Token is encrypted and if it is encrypted, then (a)
reject the token exchange request when the {@link
Service#isTokenExchangeEncryptedJwtRejected()
tokenExchangeEncryptedJwtRejected} flag of the service is
trueor (b) skip remaining validation steps when the flag isfalse. Note that Authlete does not verify an encrypted ID Token because there is no standard way to obtain the key to decrypt the ID Token with in the context of token exchange where the client ID for the encrypted ID Token cannot be determined. This means that you must verify an encrypted ID Token by yourself when one is used as an input token with the token type"urn:ietf:params:oauth:token-type:id_token". - Confirm that the ID Token contains the
expclaim and the current time has not reached the time indicated by the claim. - Confirm that the ID Token contains the
iatclaim and the current time is equal to or after the time indicated by the claim. - Confirm that the current time is equal to or after the time indicated
by the
nbfclaim if the ID Token contains the claim. - Confirm that the ID Token contains the
issclaim and the value is a valid URI. In addition, confirm that the URI has thehttpsscheme, no query component and no fragment component. - Confirm that the ID Token contains the
audclaim and its value is a JSON string or an array of JSON strings. - Confirm that the value of the
nonceclaim is a JSON string if the ID Token contains the claim. - Check if the ID Token is signed and if it is not signed, then (a)
reject the token exchange request when the {@link
Service#isTokenExchangeUnsignedJwtRejected()
tokenExchangeUnsignedJwtRejected} flag of the service is
trueor (b) finish validation on the input token. - Confirm that the signature algorithm is asymmetric. This implies that
ID Tokens whose signature algorithm is symmetric (
HS256,HS384orHS512) cannot be used as a subject token or an actor token with the token typeurn:ietf:params:oauth:token-type:id_token. - Verify the signature of the ID Token. Signature verification is
performed even in the case where the issuer of the ID Token is not
your service. But in that case, the issuer must support the discovery
endpoint defined in OpenID
Connect Discovery 1.0. Otherwise, signature verification fails.
*Token Type:
urn:ietf:params:oauth:token-type:saml1* (Authlete does not perform any validation for this token type.) *Token Type:urn:ietf:params:oauth:token-type:saml2* (Authlete does not perform any validation for this token type.) The specification of Token Exchange (RFC 8693) is very flexible. In other words, the specification has abandoned the task of determining details. Therefore, for secure token exchange, you have to complement the specification with your own rules. For that purpose, Authlete provides some configuration options as listed below. Authorization server implementers may utilize them and/or implement their own rules. In the case of {@link Action#TOKEN_EXCHANGE TOKEN_EXCHANGE}, the {@link #getResponseContent()} method returnsnull. You have to construct the token response by yourself. For example, you may generate an access token by calling Authlete’s/api/auth/token/createAPI and construct a token response like below.
JWT_BEARER JWT_BEARER (Authlete 2.3 onwards)
When the value of"action" is "JWT_BEARER", it means that
the request from the client application is a valid token request with the
grant type "urn:ietf:params:oauth:grant-type:jwt-bearer" (RFC 7523 JSON Web Token (JWT)
Profile for OAuth 2.0 Client Authentication and Authorization Grants)
and that the request has already passed the following validation steps.- Confirm that the
assertionrequest parameter is given and its value is not empty. - Confirm that the format of the assertion conforms to the JWT specification (RFC 7519).
- Check if the JWT is encrypted and if it is encrypted, then (a) reject the
token request when the {@link Service#isJwtGrantEncryptedJwtRejected()
jwtGrantEncryptedJwtRejected} flag of the service is
trueor (b) skip remaining validation steps when the flag isfalse. Note that Authlete does not verify an encrypted JWT because there is no standard way to obtain the key to decrypt the JWT with. This means that you must verify an encrypted JWT by yourself. - Confirm that the JWT contains the
issclaim and its value is a JSON string. - Confirm that the JWT contains the
subclaim and its value is a JSON string. - Confirm that the JWT contains the
audclaim and its value is either a JSON string or an array of JSON strings. - Confirm that the issuer identifier of the service (cf. {@link Service#getIssuer()})
or the URL of the token endpoint (cf. {@link Service#getTokenEndpoint()})
is listed as audience in the
audclaim. - Confirm that the JWT contains the
expclaim and the current time has not reached the time indicated by the claim. - Confirm that the current time is equal to or after the time indicated by
by the
iatclaim if the JWT contains the claim. - Confirm that the current time is equal to or after the time indicated by
by the
nbfclaim if the JWT contains the claim. - Check if the JWT is signed and if it is not signed, then (a) reject the
token request when the {@link Service#isJwtGrantUnsignedJwtRejected()
jwtGrantUnsignedJwtRejected} flag of the service is
trueor (b) finish validation on the JWT. Note that Authlete does not verify the signature of the JWT because there is no standard way to obtain the key to verify the signature of a JWT with. This means that you must verify the signature by yourself. Authlete provides some configuration options for the grant type as listed below. Authorization server implementers may utilize them and/or implement their own rules.
assertion request parameter. You must verify the
signature by yourself.Authorizations
Authenticate every request with a Service Access Token or Organization Token.
Set the token value in the Authorization: Bearer <token> header.
Service Access Token: Scoped to a single service. Use when automating service-level configuration or runtime flows.
Organization Token: Scoped to the organization; inherits permissions across services. Use for org-wide automation or when managing multiple services programmatically.
Both token types are issued by the Authlete console or provisioning APIs.
Path Parameters
A service ID.
Body
OAuth 2.0 token request parameters which are the request parameters that the OAuth 2.0 token endpoint of the authorization server implementation received from the client application.
The value of parameters is the entire entity body (which is formatted in application/x-www-form-urlencoded) of the request from
the client application.
The client ID extracted from Authorization header of the token request from the client application.
If the token endpoint of the authorization server implementation supports basic authentication as
a means of client authentication, and the request from the client application contained its client ID
in Authorization header, the value should be extracted and set to this parameter.
The client secret extracted from Authorization header of the token request from the client application.
If the token endpoint of the authorization server implementation supports basic authentication as a means of
client authentication, and the request from the client application contained its client secret in Authorization header,
the value should be extracted and set to this parameter.
The client certificate from the MTLS of the token request from the client application.
The certificate path presented by the client during client authentication. These certificates are strings in PEM format.
Extra properties to associate with an access token. See Extra Properties for details.
DPoP header presented by the client during the request to the token endpoint.
The header contains a signed JWT which includes the public key that is paired with the private key used to sign the JWT. See OAuth 2.0 Demonstration of Proof-of-Possession at the Application Layer (DPoP) for details.
HTTP method of the token request. This field is used to validate the DPoP header.
In normal cases, the value is POST. When this parameter is omitted, POST is used as the default value.
See OAuth 2.0 Demonstration of Proof-of-Possession at the Application Layer (DPoP)
for details.
URL of the token endpoint. This field is used to validate the DPoP header.
If this parameter is omitted, the tokenEndpoint property of the Service is used as the default value.
See OAuth 2.0 Demonstration of Proof-of-Possession at the Application Layer (DPoP)
for details.
The representation of an access token that may be issued as a result of the Authlete API call.
Additional claims that are added to the payload part of the JWT access token.
The value of the OAuth-Client-Attestation HTTP header, which is defined in the specification
of OAuth 2.0 Attestation-Based Client Authentication.
The value of the OAuth-Client-Attestation-PoP HTTP header, which is defined in the specification
of OAuth 2.0 Attestation-Based Client Authentication.
The duration (in seconds) of the access token that may be issued as a result of the Authlete API call.
When this request parameter holds a positive integer, it is used as the duration of the access token in. In other cases, this request parameter is ignored.
The duration (in seconds) of the refresh token that may be issued as a result of the Authlete API call.
When this request parameter holds a positive integer, it is used as the duration of the refresh token in. In other cases, this request parameter is ignored.
The flag indicating whether to require the DPoP proof JWT to include the nonce claim. Even if
the service's dpopNonceRequired property is false, calling the /auth/token API with this
dpopNonceRequired parameter true will force the Authlete API to check whether the DPoP proof
JWT includes the expected nonce value.
Options for OAuth Client ID Metadata Document (CIMD).
These options allow per-request control over CIMD behavior, taking precedence over service-level configuration when provided.
Response
Token operation completed successfully
The code which represents the result of the API call.
A short message which explains the result of the API call.
The next action that the authorization server implementation should take.
INTERNAL_SERVER_ERROR, INVALID_CLIENT, BAD_REQUEST, PASSWORD, OK, TOKEN_EXCHANGE, JWT_BEARER, NATIVE_SSO, ID_TOKEN_REISSUABLE The content that the authorization server implementation is to return to the client application.
Its format varies depending on the value of action parameter.
The value of username request parameter in the token request.
The client application must specify username when it uses Resource Owner Password Grant.
In other words, when the value of grant_type request parameter is password, username request parameter must come along.
This parameter has a value only if the value of grant_type request parameter is password and the token request is valid.
The value of password request parameter in the token request.
The client application must specify password when it uses Resource Owner Password Grant.
In other words, when the value of grant_type request parameter is password, password request parameter must come along.
This parameter has a value only if the value of grant_type request parameter is password and the token request is valid.
The ticket which is necessary to call Authlete's /auth/token/fail API or /auth/token/issue API.
This parameter has a value only if the value of grant_type request parameter is password and the token request is valid.
The newly issued access token.
The datetime at which the newly issued access token will expire. The value is represented in milliseconds since the Unix epoch (1970-01-01).
The duration of the newly issued access token in seconds.
The newly issued refresh token.
The datetime at which the newly issued refresh token will expire. The value is represented in milliseconds since the Unix epoch (1970-01-01).
The duration of the newly issued refresh token in seconds.
The newly issued ID token. Note that an ID token is issued from a token endpoint only when the response_type request parameter
of the authorization request to an authorization endpoint has contained code and the scope request parameter has contained openid.
The grant type of the token request.
The client ID.
The client ID alias when the token request was made. If the client did not have an alias, this parameter is null.
Also, if the token request was invalid and it failed to identify a client, this parameter is null.
The flag which indicates whether the client ID alias was used when the token request was made.
true if the client ID alias was used when the token request was made.
The subject (= resource owner's ID) of the access token.
Even if an access token has been issued by the call of /api/auth/token API, this parameter is null if the flow of the token request was
Client Credentials Flow (grant_type=client_credentials) because it means the access token
is not associated with any specific end-user.
The scopes covered by the access token.
The extra properties associated with the access token.
This parameter is null when no extra property is associated with the issued access token.
The newly issued access token in JWT format. If the authorization server is configured
to issue JWT-based access tokens (= if the service's accessTokenSignAlg value is a
non-null value), a JWT-based access token is issued along with the original random-string
one.
The resources specified by the resource request parameters in the token request.
See "Resource Indicators for OAuth 2.0" for details.
The target resources of the access token being issued. See "Resource Indicators for OAuth 2.0" for details.
The authorization details. This represents the value of the authorization_details
request parameter in the preceding device authorization request which is defined in
"OAuth 2.0 Rich Authorization Requests".
Additional claims to be embedded in an ID token.
The attributes of this service that the client application belongs to.
The attributes of the client.
The client authentication method that was performed at the token endpoint.
the value of the grant_id request parameter of the device authorization request.
The grant_id request parameter is defined in
Grant Management for OAuth 2.0
, which is supported by Authlete 2.3 and newer versions.
The audiences on the token exchange request
The token type identifier used in OAuth 2.0 Token Exchange (RFC 8693). The API returns short codes (enum constant names) in response fields.
JWT, ACCESS_TOKEN, REFRESH_TOKEN, ID_TOKEN, SAML1, SAML2, DEVICE_SECRET, DEVICE_CODE, TOKEN_EXCHANGE, JWT_BEARER The token type identifier used in OAuth 2.0 Token Exchange (RFC 8693). The API returns short codes (enum constant names) in response fields.
JWT, ACCESS_TOKEN, REFRESH_TOKEN, ID_TOKEN, SAML1, SAML2, DEVICE_SECRET, DEVICE_CODE, TOKEN_EXCHANGE, JWT_BEARER The token type identifier used in OAuth 2.0 Token Exchange (RFC 8693). The API returns short codes (enum constant names) in response fields.
JWT, ACCESS_TOKEN, REFRESH_TOKEN, ID_TOKEN, SAML1, SAML2, DEVICE_SECRET, DEVICE_CODE, TOKEN_EXCHANGE, JWT_BEARER For RFC 7523 JSON Web Token (JWT) Profile for OAuth 2.0 Client Authentication and Authorization Grants
Indicate whether the previous refresh token that had been kept in the database for a short time was used
The entity ID of the client.
Flag which indicates whether the entity ID of the client was used when the request for the access token was made.
Duration of the c_nonce in seconds.
Get the expected nonce value for DPoP proof JWT, which should be used
as the value of the DPoP-Nonce HTTP header.
Get the c_nonce.
Get the time at which the c_nonce expires in milliseconds since
the Unix epoch (1970-01-01).
Get the names of the claims that the authorization request (which resulted in generation of the access token) requested to be embedded in ID tokens.
Scopes associated with the refresh token.
The session ID, which is the ID of the user's authentication session, associated with a newly created access token.
If the response from the /auth/token API contains the deviceSecret parameter, its value should
be used as the value of this deviceSecret request parameter to the /nativesso API. The authorization
server may choose to issue a new device secret; in that case, it is free to generate a new device
secret and specify the new value.
The authorization server should compute the hash value of the device secret based on its own logic
and specify the computed hash as the value of this deviceSecretHash request parameter to the
/nativesso API.
The location of the client's metadata document that was used to resolve client metadata.
This property is set when client metadata was retrieved via the OAuth Client ID Metadata Document (CIMD) mechanism.
Flag indicating whether a metadata document was used to resolve client metadata for this request.
When true, the client metadata was retrieved via the CIMD mechanism rather than from the Authlete database.