/auth.js Secret
Created
May 27, 2024 15:19
generate a simple JWT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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