These snippets sign the same claims with HS256 and the placeholder secret your-jwt-secret-key. Use them only as a local test. jsonwebtoken 9 and PyJWT 2 produce the token in the example above. firebase/php-jwt 6 writes typ before alg in the header, so its encoded string differs; the payload, algorithm, and secret are the same.
Node.js (jsonwebtoken)
const jwt = require('jsonwebtoken');
const token = jwt.sign({
exp: 1910347200,
iat: 1894708800,
nbf: 1894708800,
iss: 'example-issuer',
sub: 'user-123',
aud: 'example-api',
jti: 'example-token-1'
}, 'your-jwt-secret-key', { algorithm: 'HS256' });
Python (PyJWT)
import jwt
token = jwt.encode({
"exp": 1910347200,
"iat": 1894708800,
"nbf": 1894708800,
"iss": "example-issuer",
"sub": "user-123",
"aud": "example-api",
"jti": "example-token-1",
}, "your-jwt-secret-key", algorithm="HS256")
PHP (firebase/php-jwt)
use Firebase\JWT\JWT;
$token = JWT::encode([
'exp' => 1910347200,
'iat' => 1894708800,
'nbf' => 1894708800,
'iss' => 'example-issuer',
'sub' => 'user-123',
'aud' => 'example-api',
'jti' => 'example-token-1',
], 'your-jwt-secret-key', 'HS256');
For the RS256 option on this page, give those libraries an unencrypted PKCS#8 or PKCS#1 RSA private key of 2048 bits or stronger and set the algorithm to RS256. Encrypted keys and public keys are rejected here.