Types
CdpTokenGenerator: Unified token generator for CDP authentication. Generates bearer tokens and optionally wallet auth tokens in a single call. This class composes the existing JwtGenerator and WalletJwtGenerator to provide a simplified, unified API. Example usage: // With wallet secret for write operations CdpTokenGenerator generator = new CdpTokenGenerator( “api-key-id”, “api-key-secret”, Optional.of(“wallet-secret”)); CdpTokenRequest request = CdpTokenRequest.builder() .requestMethod(“POST”) .requestPath(“/v2/evm/accounts”) .includeWalletAuthToken(true) .requestBody(Map.of(“name”, “my-account”)) .build(); CdpTokenResponse tokens = generator.generateTokens(request); // tokens.bearerToken() - for Authorization header // tokens.walletAuthToken() - for X-Wallet-Auth headerCdpTokenRequest: Configuration for generating CDP authentication tokens. This unified request object supports generating both bearer tokens and optional wallet auth tokens in a single call. Example usage: CdpTokenRequest request = CdpTokenRequest.builder() .requestMethod(“POST”) .requestPath(“/v2/evm/accounts”) .includeWalletAuthToken(true) .requestBody(Map.of(“name”, “my-account”)) .build();CdpTokenResponse: Response containing generated CDP authentication tokens. Always contains a bearer token. Optionally contains a wallet auth token ifincludeWalletAuthTokenwas set to true in the request. This class implements TokenProvider and can be used wherever token providers are accepted, such as in CDP client factory methods. Example usage: CdpTokenResponse response = generator.generateTokens(request); // Bearer token for Authorization header StringbearerToken= response.bearerToken(); // Wallet auth token for X-Wallet-Auth header (if requested) response.walletAuthToken().ifPresent(walletJwt-> { // Use wallet JWT }); // Use as TokenProvider CdpClient client = CdpClient.builder() .tokenProvider(response) .build(); EvmClientevmClient= client.evm();HashUtils: Utility class for cryptographic hashing operations.JsonUtils: Utility class for JSON operations. Provides functionality for sorting JSON object keys recursively, which is required for computing consistent request hashes.JwtGenerator: Generates JWT tokens for authenticating with Coinbase APIs. Supports both EC (ES256) and Ed25519 (EdDSA) keys. The key type is automatically detected based on the key format. Example usage: // Generate JWT for REST API String jwt = JwtGenerator.generateJwt( JwtOptions.builder(“key-id”, “key-secret”) .requestMethod(“GET”) .requestHost(“api.cdp.coinbase.com”) .requestPath(“/platform/v1/wallets”) .build()); // Generate JWT for WebSocket (no URI claims) StringwsJwt= JwtGenerator.generateJwt( JwtOptions.builder(“key-id”, “key-secret”).build());JwtOptions: Configuration options for JWT generation. Supports both EC (ES256) and Ed25519 (EdDSA) keys. For REST API requests, all request parameters (method, host, path) must be provided. For WebSocket JWTs, all request parameters should be null. Example usage: // REST API JWT JwtOptions options = JwtOptions.builder(“key-id”, “key-secret”) .requestMethod(“GET”) .requestHost(“api.cdp.coinbase.com”) .requestPath(“/platform/v1/wallets”) .expiresIn(120) .build(); // WebSocket JWT (no URI claims) JwtOptionswsOptions= JwtOptions.builder(“key-id”, “key-secret”).build();KeyParser: Parses private keys from various formats. Supports: PEM-encoded EC keys (ES256) Base64-encoded Ed25519 keys (64 bytes: 32-byte seed + 32-byte public key) Base64-encoded PKCS#8 DER keys (for wallet secrets)TokenProvider: Provides authentication tokens for CDP API requests. This interface defines the contract for supplying bearer tokens and optional wallet auth tokens to CDP clients. It allows for flexible token provisioning from various sources, including internal token generators, external authentication services, or custom token management systems. Implementations must provide: A bearer token for the Authorization header An optional wallet auth token for the X-Wallet-Auth header Example implementation for a custom token source: public class ExternalTokenProvider implements TokenProvider { private final ExternalAuthServiceauthService; public ExternalTokenProvider(ExternalAuthServiceauthService) { this.authService=authService; } @Override public StringbearerToken() { returnauthService.getBearerToken(); } @Override public Optional<String>walletAuthToken() { returnauthService.getWalletAuthToken(); } } // Usage with CDP clients TokenProvider tokens = new ExternalTokenProvider(authService); CdpClient client = CdpClient.builder() .tokenProvider(tokens) .build(); EvmClientevmClient= client.evm(); PoliciesClientpoliciesClient= client.policies(); The SDK provides a default implementation via CdpTokenResponse that is returned by CdpTokenGenerator.WalletJwtGenerator: Generates Wallet Auth JWT tokens for authenticating with wallet-specific endpoints. Wallet JWTs are required for write operations (POST, PUT, DELETE) on account and spend-permission endpoints. They include a hash of the request body for integrity verification. Example usage: StringwalletJwt= WalletJwtGenerator.generateWalletJwt( new WalletJwtOptions(walletSecret, “POST”, “api.cdp.coinbase.com”, “/platform/v1/accounts”, Map.of(“name”, “my-account”) ));WalletJwtOptions: Configuration options for Wallet Auth JWT generation. Wallet JWTs are used to authenticate write operations on account endpoints. They include a hash of the request body for integrity verification. Example usage: WalletJwtOptions options = new WalletJwtOptions(walletSecret, “POST”, “api.cdp.coinbase.com”, “/platform/v1/accounts”, Map.of(“name”, “my-account”) );