Create a JWT token using your private key
import jsonwebtoken from "jsonwebtoken";
import fs from "node:fs";
const privateKey = fs.readFileSync("private.pem").toString();
const jwt = jsonwebtoken.sign({}, privateKey, {
issuer: this.url,
subject: this.company_id,
audience: 'brouwervos.nl',
algorithm: 'RS256',
});
console.log(jwt);import jwt
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
with open("private.pem", "rb") as key_file:
private_key = serialization.load_pem_private_key(
key_file.read(),
password=None,
backend=default_backend()
)
token = jwt.encode({}, private_key, algorithm="RS256", headers={
"iss": "YourIssuerUrl",
"sub": "YourCompanyId",
"aud": "brouwervos.nl"
})
print(token)Last updated