Skip to content

Instantly share code, notes, and snippets.

@cezar-plescan
Created May 27, 2024 15:19
generate a simple JWT
const jwt = require('jsonwebtoken');
// Replace with your actual secret key
const secretKey = 'my_secret_key';
// Define the payload
const payload = {
userId: 123,
username: 'johndoe',
email: 'john.doe@example.com'
};
// Set token expiration
const options = {
expiresIn: '1h'
};
// Generate the JWT
const token = jwt.sign(payload, secretKey, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment