Skip to content

OAuth2 Token Endpoint

POST
/oauth2/access_token
curl --request POST \
--url https://api.example.com/oauth2/access_token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data client_id=example \
--data client_secret=example \
--data code=example \
--data redirect_uri=https://example.com \
--data code_verifier=example \
--data refresh_token=example \
--data username=example \
--data password=example

Exchanges authorization codes or refresh tokens for access tokens.

Media typeapplication/x-www-form-urlencoded
One of:
object
grant_type
required

Grant type, must be authorization_code or refresh_token or password or otp or activation

string
Allowed values: authorization_code refresh_token password otp activation
client_id
required

The client application’s identifier.

string
client_secret

The client application’s secret.

string
code
required

Authorization code received from the /oauth2/authorize endpoint, the OTP code, or the account activation code.

string
redirect_uri
required

The same redirect URI used in the authorization request.

string format: uri
code_verifier
required

Original code verifier used in PKCE flow.

string
refresh_token

Refresh token for obtaining new access tokens.

string
username

Customer e-mail, or for third-party authentication, use the values facebook, google, or apple. See documentation.

string
password

Plain-text password or JSON-encoded string of token, source, and name. See documentation.

string

Successful token response.

Media typeapplication/json
object
access_token

The access token issued by the authorization server.

string
token_type

The type of the token issued (typically ‘Bearer’).

string
expires_in

Lifetime in seconds of the access token.

integer
refresh_token

Refresh token to obtain new access tokens.

string
scope

Scopes granted to the access token.

string

Example generated

{
"access_token": "example",
"token_type": "example",
"expires_in": 1,
"refresh_token": "example",
"scope": "example"
}

Invalid request or authorization code.

Invalid client credentials or unauthorized request.