Authentication Overview
The CDP SDK Python library provides authentication utilities for generating JWT tokens and managing authenticated HTTP requests. These utilities support both EC (ES256) and Ed25519 (EdDSA) keys.JWT Generation
generate_jwt
The configuration options for generating the JWT.
The generated JWT (Bearer token) string.
If required parameters are missing, invalid, or if JWT signing fails.
JwtOptions
Configuration options for JWT generation.The API key ID. Examples:
'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx''organizations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apiKeys/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
The API key secret. Examples:
'xxxxxx...xx=='(Edwards key Ed25519)'-----BEGIN EC PRIVATE KEY-----\n...\n-----END EC PRIVATE KEY-----\n'(EC key ES256)
The HTTP method for the request (e.g. ‘GET’, ‘POST’), or None for JWTs intended for websocket connections.
The host for the request (e.g. ‘api.cdp.coinbase.com’), or None for JWTs intended for websocket connections.
The path for the request (e.g. ‘/platform/v1/wallets’), or None for JWTs intended for websocket connections.
Optional expiration time in seconds (defaults to 120).
Optional audience claim for the JWT.
generate_wallet_jwt
The configuration options for generating the wallet auth JWT.
The generated JWT (Bearer token) string.
If required parameters are missing or if JWT signing fails.
WalletJwtOptions
Configuration options for Wallet Auth JWT generation.The wallet authentication key.
The HTTP method for the request (e.g. ‘GET’, ‘POST’).
The host for the request (e.g. ‘api.cdp.coinbase.com’).
The path for the request (e.g. ‘/platform/v1/wallets//addresses’).
The request data for the request (e.g.
{"wallet_id": "1234567890"}).HTTP Authentication
get_auth_headers
The options for generating auth headers.
Dictionary of authentication headers.
GetAuthHeadersOptions
The API key ID.
The API key secret.
The HTTP method.
The request host.
The request path.
Optional request body.
Optional wallet secret.
Optional source identifier.
Optional source version.
Optional JWT expiration time in seconds.
WebSocket Authentication
get_websocket_auth_headers
The options for generating WebSocket auth headers.
Dictionary of authentication headers for WebSocket.
GetWebSocketAuthHeadersOptions
The API key ID.
The API key secret.
Authenticated HTTP Client
Urllib3AuthClient
HTTP client that automatically adds authentication headers to requests.The authentication configuration options.
The base URL for all requests.
Whether to enable debug logging.
Urllib3AuthClientOptions
The API key ID.
The API key secret.
Optional wallet secret.
Optional source identifier.
Optional source version.
Optional JWT expiration time in seconds.
request
The HTTP method.
The URL to request (relative or absolute).
Optional additional headers.
Optional request body (can be a dict for JSON or bytes).
Additional arguments passed to urllib3.request().
The HTTP response.
Key Format Support
The authentication utilities support two types of private keys:EC Keys (ES256)
PEM-formatted EC private keys:Ed25519 Keys (EdDSA)
Base64-encoded Ed25519 private keys (64 bytes):The library automatically detects the key type and uses the appropriate signing algorithm.