Skip to main content

Overview

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

In This Recipe

  1. Install Dependencies
  2. Create signJWT function
  3. Usage - GET Request
  4. Usage - POST Request

Prerequisites

  • Go 1.18 or higher
  • Your Issuing API credentials (Access Key and RSA key pair)

Step 1: Install Dependencies

Install the required Go modules:

Step 2: Create signJWT Function

Create a utility function 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: PEM-encoded PKCS8 or PKCS1
  • Empty body: Use empty string "" for GET requests

Step 3: Usage - GET Request

Make a simple GET request to test connectivity:

Step 4: Usage - POST Request

Make a POST request with a request body:

Common Pitfalls

Body Hashing is Critical! The SignJWT function 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 request.
Token Expiration: JWT tokens expire after 30 seconds. Generate a fresh token for each API request to avoid authentication errors.

Next Steps