ValidationError: "expiresInMinutes" no está permitido NodeJS JsonWebToken
Estoy usando NodeJS con el módulo JsonWebtoken.
Me enfrento a este error al llamar al método sign de json web token
ValidationError:" expiresInMinutes " no está permitido
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
});
}
60
Author: Abdul Rehman Sayed, 2016-06-04
3 answers
Ok encontré eso de https://www.npmjs.com/package/jsonwebtoken
Tienes que llamar a expiresIn en lugar de expiresInMinutes.
var token = jwt.sign(user, req.app.get('jwtTokenSecret'), {
expiresIn : 60*60*24
});
Aquí el valor de expiresIn
se mide en segundos en lugar de minutos, por lo que el valor tiene que ser puesto correctamente.
122
Author: Abdul Rehman Sayed,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-18 11:43:52
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-18 11:43:52
expiresInMinutes
estaba en desuso, debe usar expiresIn: '1440m'
por ejemplo
18
Author: kaxi1993,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-04 11:23:04
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-04 11:23:04
expiresInMinutes
está en desuso, use expiresIn
en su lugar. De los documentos :
expiresIn
: expresado en segundos o una cadena que describe un lapso de tiempo rauchg / ms . Por ejemplo: 60," 2 días"," 10h","7d"
6
Author: edelans,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-10 23:17:05
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-09-10 23:17:05