Skip to main content

Overview

The following methods can be used to authenticate your requests to the Coinbase Developer Platform (CDP). Choose the method that best suits your needs: Visit the CDP Authentication docs for more details.

Generate a JWT

The following example shows how to generate a JWT token, which can then be injected manually into your Authorization header to authenticate REST API requests to the CDP APIs using the HTTP request library of your choice. Step 1: Install the required package:
Step 2: Generate a JWT:
For information about the above parameters, please refer to the Authentication parameters section. Step 3: Use your JWT (Bearer token) in the Authorization header of your HTTP request:

Generate your authorization headers

The following example shows how to generate the required authentication headers for authenticating a request to the CDP REST APIs, using the HTTP request library of your choice. Step 1: Install the required package:
Step 2: Generate authorization headers:
For information about the above parameters, please refer to the Authentication parameters section.

Use an Axios request interceptor

Step 1: Install the required packages:
Step 2: Create an authenticated Axios client: The following example shows how to use an Axios HTTP client with a pre-configured interceptor to authenticate your requests to the CDP REST APIs. This client will automatically add the appropriate authentication headers to each request.
The Axios interceptor will automatically:
  • Generate a JWT for each request
  • Add the JWT to the Authorization header
  • Set the appropriate Content-Type header
  • Add wallet authentication when required
For information about the above parameters, please refer to the Authentication parameters section.

Authentication parameters

The following table provides more context of many of the authentication parameters used in the examples above: * Either all three request parameters (requestMethod, requestHost, and requestPath) must be provided for REST API requests, or all three must be null for JWTs intended for websocket connections.