Skip to main content
Package: com.coinbase.cdp.auth
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:

Constructor Details

CdpTokenGenerator

Overload 1
Creates a new token generator with default expiration. Parameters: apiKeyId (String) - the API key ID apiKeySecret (String) - the API key secret (PEM EC key or base64 Ed25519 key) walletSecret (Optional<String>) - optional wallet secret for wallet auth tokens Overload 2
Creates a new token generator with custom expiration. Parameters: apiKeyId (String) - the API key ID apiKeySecret (String) - the API key secret (PEM EC key or base64 Ed25519 key) walletSecret (Optional<String>) - optional wallet secret for wallet auth tokens expiresIn (long) - JWT expiration time in seconds

Method Details

generateTokens

Generates authentication tokens based on the request configuration. Parameters: request (CdpTokenRequest) - the token request configuration Returns: CdpTokenResponse - the generated tokens Throws: [WalletSecretException](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/exceptions/WalletSecretException "class in com.coinbase.cdp.auth.exceptions") - if wallet auth is requested but no wallet secret is configured

generateBearerToken

Generates only a bearer token (convenience method). Parameters: method (String) - the HTTP method host (String) - the request host path (String) - the request path Returns: String - the bearer token

hasWalletSecret

Returns whether this generator has a wallet secret configured. Returns: boolean - true if wallet secret is available