Clients using our APIs are authenticated using the OAuth 2.0 client_credentials grant type.
We will issue you with a unique client_id and client_secret, which you use to authenticate directly with our authorization server to obtain short-lived access tokens. You then include the access token in subsequent API requests as a Bearer token in the Authorization header.
POST /oauth2/tokens
Authorization: Basic {base64(client_id:client_secret)}
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentialsIf authentication is successful, the authorization server will return an access token.
200 OK
{
"access_token": "DhFDAXfadrMAdbwxh9JNsMi5i7GF",
"token_type": "Bearer",
"expires_in": 900
}| Field | Description |
|---|---|
access_token | The token to be used to authenticate API requests. |
token_type | The authentication scheme. This will always be Bearer. |
expires_in | The token's lifetime in seconds. |
The response may contain other fields which we have excluded for simplicity. Other response fields are not always returned and you must not use, validate or expect them in any way.
Include the token in the Authorization header of all subsequent API requests.
Authorization: Bearer DhFDAXfadrMAdbwxh9JNsMi5i7GFAccess tokens must be cached and reused for multiple API requests until they approach expiry.
To avoid authentication failures caused by token expiration, network latency, or retries, we recommend requesting a new access token after approximately 70-80% of the current token's lifetime has elapsed.
For example, for a token with a lifetime of 900 seconds (15 minutes), request a replacement token after approximately 10-12 minutes.
Your applications should continue to use the current token until the replacement token has been successfully acquired, and then switch to the new token before the previous token expires.
Always request a new token at 70-80% of the current token's lifetime to allow for network jitters and retries, and switch to the new access token shortly before the expiry of the previous one.
Do not request a new access token for every payment request. This will significantly impact your latency and may result in rate limiting.
- You must treat the token as an opaque string.
- You must support token lengths up to 8 KB.
- You must use the
expires_invalue to determine the lifetime of the token. - You must not assume any specific token format or structure.
- You must not try to inspect, parse, decode, or validate token contents.
- You must not assume token contents will remain unchanged over time.
- The lifespan (TTL) of a token must not be considered a fixed value and must not be hardcoded.
The internal token format, encoding, structure, and claims may change at any time without notice. Such changes are not considered to be breaking changes.
Basic authentication remains available for clients on request.
If you have been issued with basic authentication credentials and would like to switch to OAuth2, please speak to your Implementation Manager.
For clientside SDKs, we create a public checkoutId that we map to your account's API credentials. Use this to initialize the SDK.