pub struct JwtOptions {
pub api_key_id: String,
pub api_key_secret: String,
pub request_method: Option<String>,
pub request_host: Option<String>,
pub request_path: Option<String>,
pub expires_in: Option<u64>,
pub audience: Option<Vec<String>>,
}Expand description
Configuration options for standalone JWT generation.
This struct holds all necessary parameters for generating a JWT token for authenticating with the Coinbase Developer Platform (CDP) REST APIs. It supports both EC (ES256) and Ed25519 (EdDSA) keys.
When request_method, request_host, and request_path are all None,
the uris claim is omitted from the JWT (useful for websocket connections).
§Examples
use cdp_sdk::auth::{generate_jwt, JwtOptions};
// For REST API requests
let jwt = generate_jwt(JwtOptions::builder()
.api_key_id("your-api-key-id".to_string())
.api_key_secret("your-api-key-secret".to_string())
.request_method("GET".to_string())
.request_host("api.cdp.coinbase.com".to_string())
.request_path("/platform/v2/evm/accounts".to_string())
.build()
)?;Fields§
§api_key_id: StringThe API key ID. Supported formats:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxorganizations/{orgId}/apiKeys/{keyId}
api_key_secret: StringThe API key secret. Supported formats:
- Edwards key (Ed25519): base64-encoded 64-byte key
- Elliptic Curve key (ES256): PEM-encoded EC private key
request_method: Option<String>HTTP method (e.g. “GET”, “POST”). None for websocket JWTs.
request_host: Option<String>Request host (e.g. “api.cdp.coinbase.com”). None for websocket JWTs.
request_path: Option<String>Request path (e.g. “/platform/v2/evm/accounts”). None for websocket JWTs.
expires_in: Option<u64>JWT expiration time in seconds. Defaults to 120 (2 minutes).
audience: Option<Vec<String>>Optional audience claim for the JWT.
Implementations§
Source§impl JwtOptions
impl JwtOptions
pub fn builder() -> JwtOptionsBuilder
Trait Implementations§
Source§impl Clone for JwtOptions
impl Clone for JwtOptions
Source§fn clone(&self) -> JwtOptions
fn clone(&self) -> JwtOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more