Created
October 1, 2020 08:53
-
-
Save darknessnerd/d4d0eb475e29ac2d074c15ec7dda2cf2 to your computer and use it in GitHub Desktop.
Build a JWT With a Private Key
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 njwt = require('njwt'); | |
const privateKey=` | |
-----BEGIN PRIVATE KEY----- | |
... | |
... | |
-----END PRIVATE KEY----- | |
` | |
const clientId = "test"; // Or load from configuration | |
const now = Math.floor( new Date().getTime() / 1000 ); // seconds since epoch | |
const claims = { | |
"name": "bRuN1N05" | |
}; | |
const jwt = njwt.create(claims, privateKey, 'RS256') | |
.setIssuedAt(now) | |
.setIssuer(clientId) | |
.compact(); | |
console.log(jwt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment