Skip to main content

Overview

This tutorial shows you how to authenticate to the Issuing API using Java by generating signed JSON Web Tokens (JWTs).

In This Recipe

  1. Add Dependencies
  2. Create AccessTokenSigner
  3. Usage - GET Request
  4. Usage - POST Request

Prerequisites

  • Java 8 or higher
  • Your Issuing API credentials (Access Key and RSA key pair)
  • Maven or Gradle for dependency management

Step 1: Add Dependencies

Add these dependencies to your pom.xml:

Step 2: Create AccessTokenSigner

Create a utility class to handle JWT signing with SHA256 body hashing:

Important Notes:

  • Request body is hashed with SHA256 before signing
  • 30 second expiration for security
  • Private key format: Base64-encoded PKCS8, no PEM headers/footers
  • Empty body: Use empty string "" for GET requests

Step 3: Usage - GET Request

Make a simple GET request to test connectivity:
This example shows JWT generation only. Use your preferred HTTP client (Apache HttpClient, OkHttp, Spring RestTemplate, etc.) to make the actual API request with the authorizationHeader.

Step 4: Usage - POST Request

Make a POST request with a request body:

Common Pitfalls

Body Hashing is Critical! The AccessTokenSigner automatically hashes the request body with SHA256 before including it in the JWT claims. Make sure you pass the exact same request body to both signJWT() and your HTTP client.
Token Expiration: JWT tokens expire after 30 seconds. Generate a fresh token for each API request to avoid authentication errors.

Next Steps