Introduction
The Criteo API allows you to build custom apps that help the world’s advertisers grow their businesses. In order for your app to function, your users will have to delegate permissions for one or more of the Criteo advertisers that they oversee. To do this, you will need to direct the user to a unique consent delegation page using a standard OAuth integration (Authorization Code Grant Type). Below we describe how to implement this flow. These guides assume you have created a developer account, are part of an organization. Instructions for getting started can be found here.Creating an Authorization code app
Once you have logged in to the Criteo Partners Portal, create a new App by clicking on ”+” in the My apps section.


Set up your OAuth parameters
Once you have defined the scope of your application, you will be able to setup what you need for the OAuth workflowParameters | Description |
|---|---|
| Your public key accessible in app credentials section. You can add up to 5 pairs of credentials. Can be added and managed also once the App has been activated. |
| Your secret key, accessible only once when creating a pair of client_id and client_secret in credentials section. You can add up to 5 pairs of credentials. Can be added and managed also once the App has been activated. |
| The URL to redirect the user to after consent delegation. Https protocol required. You can add up to 30 redirect URIs. Can be added and managed also once the App has been activated. |
Consent URL creation
Once you have defined the parameters of your App you can start implementing your authorization code flow. To request access to a user to access their data, you will create a Consent link (to be sent to the user or implemented through a button in your platform that will redirect the user to the link) with the following structure and parameters:Parameters | Description |
|---|---|
| Indicates that an authorization code is expected as outcome. |
| Your public key accessible in app credentials section. |
| The URL to redirect the user to after consent delegation. Https protocol required. Defined in the redirect URI section in Developer Dashboard. |
| A string that you can provide and that will be returned as-is in the final redirection (usually used to prevent Cross-Site Request Forgery attacks). |

- The client_id does not match any published API app.
- The redirect_uri is not authorized (e.g not accessible from public network)
- An unexpected error occurred in our backend.
Redirection and access code
Once the user has completed the Consent Delegation flow, we redirect your user to the following URL:Parameter | Description |
|---|---|
| An authorization code valid for 30 seconds, usable only once. |
| The state parameter that you originally provided (returned as-is). |
Exchanging access code for access token
Now that you have an authorization code, you can trade it for an access token with the following request:Parameter | Description |
|---|---|
| Indicates that you are providing an authorization code. |
| Authorization code returned during redirection. |
| Must match the redirect_uri used for the authorization request. |
| Your public key accessible in app credentials section. |
| Your secret key, accessible only once when creating a pair of client_id and client_secret in credentials section. |
Parameter | Description |
|---|---|
| A short-lived (valid for 900 seconds) access token* |
| A long-lived refresh token (that expires after 6 months) that can be used to renew the access token (see next section). |
| Type of token. |
| Lifetime of the token in seconds. |
Using refresh token
When an access token is close to expiration, you can get a new one using a refresh token via the following request:Parameter | Description |
|---|---|
| Indicates that you are providing a refresh token. |
| Refresh token shared when requesting an access token. |
| Your public key accessible in app credentials section. |
| Your secret key, accessible only once when creating a pair of client_id and client_secret in credentials section. |
Demo
Below you can find a code for a demo application in NodeJS that uses Express JS framework.- Run
npm install - Connect to the developer portal and create an app according to the instructions above
- Create an “Authorization code” app.
- Generate app credentials and enter the client_id and client_secret in index.js.
- Register “http://localhost:3000/criteo-auth/callback” as the redirect URI.
- Run
npm run start - Open http://localhost:3000
FAQ
What happens if my client_id and client_secret are compromised?
What happens if my client_id and client_secret are compromised?