Skip to content

Instantly share code, notes, and snippets.

@yossale
Last active October 13, 2020 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yossale/54a58fd642af403c7b2f2a51241bf97f to your computer and use it in GitHub Desktop.
Save yossale/54a58fd642af403c7b2f2a51241bf97f to your computer and use it in GitHub Desktop.
JWT Verificaiton
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