Use this guide to generate a client token that will be used in the Authorization header when calling the /generate-token API.
- OpenSSL installed
- Node.js installed
- Your Promotexter user ID from Promotexter Support (support@promotexter.com)
- npm package: jsonwebtoken
openssl genrsa -out private_key.pem 4096
openssl rsa -in private_key.pem -pubout -out public_key.pemOutput:
- private_key.pem: keep this secure, do not share
- public_key.pem: send this to Promotexter Support (support@promotexter.com)
npm install jsonwebtokenconst 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:
issuermust be your valid Promotexter user ID.expiresInmust not exceed 60 seconds. Otherwise, it will be treated as an invalid client token.- Use algorithm RS512.
- Generate a unique key pair per user.
Authorization: Bearer <your-client-token>