Skip to main content

Registering OAuth2 Client

Before integrating Coinbase App, you need to register a new OAuth2 application under your CDP API settings. If you’re using a previous OAuth2 implementation, you may need to configure the following settings:
  • Authorize URL: https://login.coinbase.com/oauth2/auth
  • Access Token URL: https://login.coinbase.com/oauth2/token

Integrating with OAuth2 Library

Coinbase recommends integrating your OAuth client with a battle-tested OAuth2 library so that you can simply plug in your client id, client secret, etc. Consider using one of the following OAuth2 libraries. For enhanced security, consider implementing PKCE (Proof Key for Code Exchange) in your OAuth2 flow.

Integrating Manually

Use the following steps if you prefer not to integrate with a well-known OAuth2 library.
To integrate your third-party web server application with Coinbase, use the following flow:

1. Redirect users to request Coinbase access

If you want to also receive refresh tokens later in the token exchange flow, add offline_access scope to your oauth2/auth request.
When redirecting a user to Coinbase to authorize access to your application, you’ll need to construct the authorization URL with the correct parameters and scopes. Here’s a list of parameters you should always specify: Example of an authorization URL:
You can further customize the authorization page and permissions. Read more at OAuth2 reference.

2. Coinbase redirects back to your site

If the user approves your application, Coinbase will redirect them back to your redirect_uri with a temporary code parameter. If you specified a state parameter in step 1, it will be returned as well. The parameter will always match the value specified in step 1. If the values don’t match, the request should not be trusted. Example of the redirect:

3. Exchange code for an access token

After you have received the temporary code, you can exchange it for valid access and refresh tokens. This can be done by making a POST call:
With following parameters: Example request:
Example request with PKCE:
After a successful request, a valid access token will be returned in the response:

4. Make an API call

After you have a valid access token, you can make your first API call:
Example response: