> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JwtGenerator

> Generates JWT tokens for authenticating with Coinbase APIs.

Package: [`com.coinbase.cdp.auth`](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/index)

```java theme={null}
public final class JwtGenerator extends Object
```

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)
 String wsJwt = JwtGenerator.generateJwt(
     JwtOptions.builder("key-id", "key-secret").build());
 
```

## Method Details

### `generateJwt`

```java theme={null}
public static String generateJwt(JwtOptions options)
```

Generates a JWT (Bearer token) for authenticating with Coinbase's REST APIs.

**Parameters:**

`options` ([JwtOptions](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/JwtOptions)) - the JWT configuration options

**Returns:**

`String` - the generated JWT string

**Throws:**

`[JwtGenerationException](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/exceptions/JwtGenerationException "class in com.coinbase.cdp.auth.exceptions")` - if token generation fails
