Skip to main content
With an OAuth integration, you can request access to a selection of your customer’s account resources. When your customer authorizes your access request, you get a token that you can use to authorize API requests on their behalf.

Integration steps

  1. Register your client
  2. Request access
  3. Get your access and refresh tokens
  4. Use your access token
  5. Refresh your access token

Requirements

To integrate with Adyen’s OAuth service, you need to have:
  • An account with the OAuth apps manage user role.
    • On our test environment, merchant accounts created since November 2023 have this role enabled by default. If your account was created before, reach out to support.
    • On our live environment, only partner accounts have the OAuth apps manage role.
We advise you first integrate in our test environment, especially when your integration involves the online payments scope.

Step 1: Register your client

An OAuth client is your application or website which accesses your customer’s account resources on their behalf. To register your OAuth client:
  1. Log in to your Partner Portal.
  2. Go to Developer > OAuth apps.
  3. Select Create OAuth app.
  4. Enter your application name, URL, and description and select Continue.
  5. Enter your Redirect URL, select the scope of access and select Continue.
    • After your customer authorizes your application, we redirect them to your Redirect URL.
  6. Copy the Client secret and store it securely. We do not store this value for you to access later.
At the moment it is not possible to extend the scopes after the OAuth app has been created. Your customer can also not select or deselect requested scopes. The authorization can only be granted with all requested scopes.

Step 2: Request access

Step 2.1: Construct the access grant URL

To request access to your customer’s account resources, you need to redirect them to an Adyen page where they authenticate and grant you access. Create the URL that points to this location, using the following reference:

Code challenge

During the OAuth flow, we use Proof Key for Code Exchange (PKCE) to add a layer of security on top of the client secret. PKCE works as follows:
  1. For every access request, you create and supply a unique code_challenge, also known as a PKCE secret.
  2. When you exchange the authorization code for the access token, you supply the associated code_verifier.
If the authorization code is intercepted, it cannot be used without the PKCE secret.
  1. To create your code_verifier, generate a random string with the following properties:
    • The string has a minimum length of 43 characters and a maximum length of 128 characters.
    • Allowed characters are [A-Z] / [a-z] / [0-9] / ”-” / ”.” / ”_” / ”~”.
  2. To create your code_challenge, create a base64url-encoded SHA256 hash of the code_verifier.

Example

  1. To create your code_verifier, generate a random URL-safe string: dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk.
  2. To create your code_challenge, base64 URL-encode the SHA256 hash of the code_verifier: E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM.

Handle the redirect

Whether the authorization was successful or failed, your customer is redirected to your redirect_uri.

Successful authorization

After successful authorization, your customer is redirected to:
In the next step, you will use the CODE to request access and refresh tokens.

Failed authorization

After failed authorization, your customer is redirected to:

Step 2.2: Redirect your customer

Add a button labeled Connect with Adyen to your application for your customers to initiate the access delegation. When your customer clicks the button, redirect them to the URL you constructed in the previous step, which points to an Adyen login screen where your customer authenticates and authorizes your request.
Then, style the button:

Step 3: Get your access and refresh tokens

Make a POST request to the /token endpoint to exchange your authorization code for:
  • A short-lived (24 hours by default) access token, to make API requests on behalf of your customer.
  • A one-time-use refresh token, to get a new access token after your previous expired.
To get your access and refresh tokens, make an HTTP POST request to:
All the parameters in the request body are x-www-form-urlencoded.

Handle the response

The response body depends on whether your request was successful or unsuccessful.

Successful response

Unsuccessful response

Step 4: Use your access token

Authorize API requests with your access token as bearer token:

Step 5: Refresh your access token

Your access token is valid until the expiry period has elapsed. Find the expiry period in the response of the /token request. Your refresh token expires only upon its usage. A short grace period is provided to allow for retries in the event of network errors or similar issues. To get a new access token, make an HTTP POST request to:
All the parameters in the request body are x-www-form-urlencoded. When you successfully refresh your access token:
  • Your previous access_token immediately expires. This ensures there is no more than one valid access_token per authorization at a given point in time.
  • Your previous refresh_token expires shortly. This lets you retry the operation if the response was lost, for example during network issues.

Successful response

The scope of access and merchant accounts that the access_token provides access to remains unchanged from when you got your access and refresh tokens.

Unsuccessful response

Go live

When you are ready to go live, make sure to:
  1. Register an OAuth client in your live Partner Portal.
  2. Change all instances of the OAuth client ID, client secret, and client URI to reflect the OAuth client in your live account.
  3. Change all API endpoints from test to live.