Last active
October 13, 2020 15:42
-
-
Save yossale/54a58fd642af403c7b2f2a51241bf97f to your computer and use it in GitHub Desktop.
JWT Verificaiton
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'); | |
const fs = require('fs') | |
function decode(token, pemFile) { | |
let cert = fs.readFileSync(pemFile); // get public key | |
jwt.verify(token, cert, function (err, decoded) { | |
if (err) { | |
console.error("Error", err) | |
} | |
console.log(`${JSON.stringify(decoded)}`) | |
}); | |
} | |
let myToken = `<YOUR_GENERATED_TOKEN>` | |
let myPem = `public.pem` | |
decode(myToken, myPem) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment