Documentation Index
Fetch the complete documentation index at: https://docs.mangopay.com/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
The Mangopay REST API uses the OAuth 2.0 authentication protocol to provide secure access to resources.Note – SDKs handle authentication automaticallyFor SDKs, the authentication is handled automatically after the initialization, relying on the OAuth 2.0 protocol. See the SDK authentication section for more details.The SDKs also handle mTLS authentication, which your platform additionally needs to integrate if you are using proxy management to take SCA-triggering actions on behalf of users.
OAuth 2.0 authentication
The OAuth 2.0 method of authentication consists in generating a temporary authentication token, called a Bearer token. This can then be used as tokenized credentials until it expires, at which point a new token must be generated. The logic is as follows: Since you only send your API key to generate the token, this industry-standard method ensures a high level of security. You need aClientId and an API key – you can create these in the Mangopay Dashboard (or else contact Sales to get started).
1. Generate a Bearer token
To generate your authentication token, call the endpoint below using Basic Access authentication as follows:A. Combine your ClientId and API key into a string separated by a colon
ClientId:ApiKey |
B. Encode the string in Base64
Once encoded, the string looks something like this:| RXhhbXBsZUNsaWVudElkOlBFQkIwVkRoRkVOZkVoWFRVeW9yVFlqNmhDVm1xTDBIUmJ3WTRnNU4xN3J1aVBqbVFu |
C. Call the OAuth token endpoint
Use the encoded string, preceded by “Basic” and a space, as your Authorization header. Unlike most other calls to the API, this endpoint supports Basic Access authentication and accepts thex-www-form-urlencoded Content-Type.
| Endpoint | POST /v2.01/oauth/token |
|---|---|
| Authorization | Basic RXhhbXBsZUNsaWVudElkOlBFQkIwVkRoRkVOZkVoWFRVeW9yVFlqNmhDVm1xTDBIUmJ3WTRnNU4xN3J1aVBqbVFu |
| Content-Type | application/x-www-form-urlencoded |
| Request body | grant_type=client_credentials |
Response example
| Property | Description |
|---|---|
access_token | The access token to use to authenticate. |
token_type | The type of token: Bearer. |
expires_in | The number of seconds until the access_token expires and a new token needs to be generated.Default values: 3600 (in Production), 1200 (in Sandbox)Note: The value may differ from the default values, therefore you should not rely on hard-coded defaults but on the expires_in value returned. |
2. Use the Bearer token for its full lifetime
Now that you have your Beareraccess_token, you can use it to authenticate all other API calls for the expires_in duration.
To do so, add it to the Authorization header of your requests, preceded by “Bearer” and a space:
| Authorization | Bearer 094696b3724d4aa5a182eac360dcd537 |
|---|
Overuse of OAuth token endpoint
3. Generate a new token before expiry
Shortly before your token expires (we recommend 30 seconds), generate a new one with the OAuth token endpoint as described in Step 1C above.HTTP errors
Once the token expires (that is, theexpires_in seconds value elapses), then it is no longer valid and calls made with it will return the following HTTP 401 error:
401 - Authorization credentials not valid
400 - Account temporarily blocked