cdp.auth.utils package¶
Submodules¶
cdp.auth.utils.http module¶
- class cdp.auth.utils.http.GetAuthHeadersOptions(**data)¶
Bases:
BaseModel
Options for generating authentication headers.
- api_key_id - The API key ID
- api_key_secret - The API key secret
- request_method - The HTTP method
- request_host - The request host
- request_path - The request path
- [request_body] - Optional request body
- [wallet_secret] - Optional wallet secret for wallet authentication
- [source] - Optional source identifier
- [source_version] - Optional source version
- [expires_in] - Optional JWT expiration time in seconds
-
api_key_id:
str
¶
-
api_key_secret:
str
¶
-
expires_in:
int
|None
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
request_body:
dict
[str
,Any
] |None
¶
-
request_host:
str
¶
-
request_method:
str
¶
-
request_path:
str
¶
-
source:
str
|None
¶
-
source_version:
str
|None
¶
-
wallet_secret:
str
|None
¶
- cdp.auth.utils.http.get_auth_headers(options)¶
Get authentication headers for a request.
- Parameters:
options (
GetAuthHeadersOptions
) – The authentication header options- Return type:
dict
[str
,str
]- Returns:
Dict with authentication headers
cdp.auth.utils.jwt module¶
- class cdp.auth.utils.jwt.JwtOptions(**data)¶
Bases:
BaseModel
Configuration options for JWT generation.
This class holds all necessary parameters for generating a JWT token for authenticating with Coinbase’s REST APIs. It supports both EC (ES256) and Ed25519 (EdDSA) keys.
- api_key_id - The API key ID
Examples
‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’ ‘organizations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apiKeys/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’
- api_key_secret - The API key secret
Examples
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==’ (Edwards key (Ed25519)) ‘—–BEGIN EC PRIVATE KEY—–\n…\n…\n…==\n—–END EC PRIVATE KEY—–\n’ (EC key (ES256))
- request_method - The HTTP method for the request
- Type:
e.g. ‘GET’, ‘POST’
- request_host - The host for the request
- Type:
e.g. ‘api.cdp.coinbase.com’
- request_path - The path for the request
- Type:
e.g. ‘/platform/v1/wallets’
- expires_in - Optional expiration time in seconds
- Type:
defaults to 120
-
api_key_id:
str
¶
-
api_key_secret:
str
¶
-
expires_in:
int
|None
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
request_host:
str
¶
-
request_method:
str
¶
-
request_path:
str
¶
- classmethod validate_request_method(v)¶
Validate the HTTP request method.
- Parameters:
v (
str
) – The request method to validate- Return type:
str
- Returns:
The validated request method in uppercase
- Raises:
ValueError – If the request method is invalid
- class cdp.auth.utils.jwt.WalletJwtOptions(**data)¶
Bases:
BaseModel
Configuration options for Wallet Auth JWT generation.
This class holds all necessary parameters for generating a Wallet Auth JWT for authenticating with endpoints that require wallet authentication.
- wallet_auth_key - The wallet authentication key
- request_method - The HTTP method for the request
- Type:
e.g. ‘GET’, ‘POST’
- request_host - The host for the request
- Type:
e.g. ‘api.cdp.coinbase.com’
- request_path - The path for the request
- Type:
e.g. ‘/platform/v1/wallets/{wallet_id}/addresses’
- request_data - The request data for the request (e.g. { "wallet_id"
“1234567890” })
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
request_data:
dict
[str
,Any
]¶
-
request_host:
str
¶
-
request_method:
str
¶
-
request_path:
str
¶
- classmethod validate_request_method(v)¶
Validate the HTTP request method.
- Parameters:
v (
str
) – The request method to validate- Return type:
str
- Returns:
The validated request method in uppercase
- Raises:
ValueError – If the request method is invalid
-
wallet_auth_key:
str
¶
- cdp.auth.utils.jwt.generate_jwt(options)¶
Generate a JWT (Bearer token) for authenticating with Coinbase’s REST APIs.
Supports both EC (ES256) and Ed25519 (EdDSA) keys.
- Parameters:
options (
JwtOptions
) – The configuration options for generating the JWT- Return type:
str
- Returns:
The generated JWT (Bearer token) string
- Raises:
ValueError – If required parameters are missing, invalid, or if JWT signing fails
- cdp.auth.utils.jwt.generate_wallet_jwt(options)¶
Build a wallet authentication JWT for the given API endpoint URL.
Used for authenticating with specific endpoints that require wallet authentication.
- Parameters:
options (
WalletJwtOptions
) – The configuration options for generating the wallet auth JWT- Return type:
str
- Returns:
The generated JWT (Bearer token) string
- Raises:
ValueError – If required parameters are missing or if JWT signing fails
Module contents¶
CDP SDK Auth Utils package.
- class cdp.auth.utils.GetAuthHeadersOptions(**data)¶
Bases:
BaseModel
Options for generating authentication headers.
- api_key_id - The API key ID
- api_key_secret - The API key secret
- request_method - The HTTP method
- request_host - The request host
- request_path - The request path
- [request_body] - Optional request body
- [wallet_secret] - Optional wallet secret for wallet authentication
- [source] - Optional source identifier
- [source_version] - Optional source version
- [expires_in] - Optional JWT expiration time in seconds
-
api_key_id:
str
¶
-
api_key_secret:
str
¶
-
expires_in:
int
|None
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
request_body:
dict
[str
,Any
] |None
¶
-
request_host:
str
¶
-
request_method:
str
¶
-
request_path:
str
¶
-
source:
str
|None
¶
-
source_version:
str
|None
¶
-
wallet_secret:
str
|None
¶
- class cdp.auth.utils.JwtOptions(**data)¶
Bases:
BaseModel
Configuration options for JWT generation.
This class holds all necessary parameters for generating a JWT token for authenticating with Coinbase’s REST APIs. It supports both EC (ES256) and Ed25519 (EdDSA) keys.
- api_key_id - The API key ID
Examples
‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’ ‘organizations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apiKeys/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’
- api_key_secret - The API key secret
Examples
‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==’ (Edwards key (Ed25519)) ‘—–BEGIN EC PRIVATE KEY—–\n…\n…\n…==\n—–END EC PRIVATE KEY—–\n’ (EC key (ES256))
- request_method - The HTTP method for the request
- Type:
e.g. ‘GET’, ‘POST’
- request_host - The host for the request
- Type:
e.g. ‘api.cdp.coinbase.com’
- request_path - The path for the request
- Type:
e.g. ‘/platform/v1/wallets’
- expires_in - Optional expiration time in seconds
- Type:
defaults to 120
-
api_key_id:
str
¶
-
api_key_secret:
str
¶
-
expires_in:
int
|None
¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
request_host:
str
¶
-
request_method:
str
¶
-
request_path:
str
¶
- classmethod validate_request_method(v)¶
Validate the HTTP request method.
- Parameters:
v (
str
) – The request method to validate- Return type:
str
- Returns:
The validated request method in uppercase
- Raises:
ValueError – If the request method is invalid
- class cdp.auth.utils.WalletJwtOptions(**data)¶
Bases:
BaseModel
Configuration options for Wallet Auth JWT generation.
This class holds all necessary parameters for generating a Wallet Auth JWT for authenticating with endpoints that require wallet authentication.
- wallet_auth_key - The wallet authentication key
- request_method - The HTTP method for the request
- Type:
e.g. ‘GET’, ‘POST’
- request_host - The host for the request
- Type:
e.g. ‘api.cdp.coinbase.com’
- request_path - The path for the request
- Type:
e.g. ‘/platform/v1/wallets/{wallet_id}/addresses’
- request_data - The request data for the request (e.g. { "wallet_id"
“1234567890” })
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
request_data:
dict
[str
,Any
]¶
-
request_host:
str
¶
-
request_method:
str
¶
-
request_path:
str
¶
- classmethod validate_request_method(v)¶
Validate the HTTP request method.
- Parameters:
v (
str
) – The request method to validate- Return type:
str
- Returns:
The validated request method in uppercase
- Raises:
ValueError – If the request method is invalid
-
wallet_auth_key:
str
¶
- cdp.auth.utils.generate_jwt(options)¶
Generate a JWT (Bearer token) for authenticating with Coinbase’s REST APIs.
Supports both EC (ES256) and Ed25519 (EdDSA) keys.
- Parameters:
options (
JwtOptions
) – The configuration options for generating the JWT- Return type:
str
- Returns:
The generated JWT (Bearer token) string
- Raises:
ValueError – If required parameters are missing, invalid, or if JWT signing fails
- cdp.auth.utils.generate_wallet_jwt(options)¶
Build a wallet authentication JWT for the given API endpoint URL.
Used for authenticating with specific endpoints that require wallet authentication.
- Parameters:
options (
WalletJwtOptions
) – The configuration options for generating the wallet auth JWT- Return type:
str
- Returns:
The generated JWT (Bearer token) string
- Raises:
ValueError – If required parameters are missing or if JWT signing fails
- cdp.auth.utils.get_auth_headers(options)¶
Get authentication headers for a request.
- Parameters:
options (
GetAuthHeadersOptions
) – The authentication header options- Return type:
dict
[str
,str
]- Returns:
Dict with authentication headers