json web tokens (JWT)

Oct 9, 04:17 AM

export JWT_SECRET_KEY=ABCD ; ## command line!

const jwt = require(“jsonwebtoken”);

const makeToken = (email) => { const expirationDate = new Date(); expirationDate.setHours(new Date().getHours() + 1); return jwt.sign({ email, expirationDate }, process.env.JWT_SECRET_KEY);
};

const myPublicToken=makeToken(‘mark@edwardsmark.com’);

console.log ( jwt.verify( myPublicToken, process.env.JWT_SECRET_KEY) );

Mark Edwards

,

---

Commenting is closed for this article.

---