I am using NodeJs with JsonWebtoken Module.
I am facing this error when calling sign method of json web token
ValidationError: "expiresInMinutes" is not allowed
var jwt = require('jsonwebtoken'); exports.authenticate = function(req, res, next) { var user = {"Name":"Abdul"} //static data for test purpose. var token = jwt.sign(user, req.app.get('jwtTokenSecret'), { expiresInMinutes: 1440 // expires in 24 hours }); // return the information including token as JSON res.json({ success: true, message: 'Enjoy your token!', token: token }); }
Ok I found that from https://www.npmjs.com/package/jsonwebtoken
You have to call expiresIn rather than expiresInMinutes.
var token = jwt.sign(user, req.app.get('jwtTokenSecret'), { expiresIn : 60*60*24 });
Here the value of expiresIn
is measured in seconds rather than minutes, so the value has to be put in properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With