Skip to content
Last updated

Generate Client Token Guide

Use this guide to generate a client token that will be used in the Authorization header when calling the /generate-token API.

Prerequisites

  1. OpenSSL installed
  2. Node.js installed
  3. Your Promotexter user ID from Promotexter Support (support@promotexter.com)
  4. npm package: jsonwebtoken

Step-by-Step Guide

Step 1: Generate RSA key pair

openssl genrsa -out private_key.pem 4096
openssl rsa -in private_key.pem -pubout -out public_key.pem

Output:

  • private_key.pem: keep this secure, do not share
  • public_key.pem: send this to Promotexter Support (support@promotexter.com)

Step 2: Install dependency

npm install jsonwebtoken

Step 3: Generate client token (Node.js sample)

const fs = require("fs");
const jwt = require("jsonwebtoken");

// Load your RSA private key
const privateKey = fs.readFileSync("private_key.pem");

// JWT signing options
const signOptions = {
	issuer: "your-promotexter-user-id",
	expiresIn: "60s",
	algorithm: "RS512"
};

// Create token
const token = jwt.sign({}, privateKey, signOptions);

console.log("Client token:");
console.log(token);

Important Notes:

  1. issuer must be your valid Promotexter user ID.
  2. expiresIn must not exceed 60 seconds. Otherwise, it will be treated as an invalid client token.
  3. Use algorithm RS512.
  4. Generate a unique key pair per user.

Step 4: Use client token in Generate Promotexter Token API request

Authorization: Bearer <your-client-token>