Closed alexxozo closed 4 years ago
From the docs:
jsonWebTokenOptions: passport-jwt is verifying the token using jsonwebtoken. Pass here an options object for any other option you can pass the jsonwebtoken verifier. (i.e maxAge)
Note that the options you will specify will get passed on to the jsonwebtoken verify method.
From jsonwebtoken docs:
maxAge: the maximum allowed age for tokens to still be valid. It is expressed in seconds or a string describing a time span zeit/ms.
So what you're actually looking for is the "maxAge" property. The expiresIn property is used in the sign method of the jsonwebtoken package.
I have tried it like this:
passport.use(new JWTStrategy({
jwtFromRequest: ExtractJWT.fromAuthHeaderAsBearerToken(),
secretOrKey: 'secret',
jsonWebTokenOptions: {
maxAge: '1'
}
}));
But it does not seem to work.
That's odd. If you are signing tokens in your code, you can try the following workaround:
jwt.sign(toSign, secret, { expiresIn: '24h' });
Also, it seems you do not provide a verify function callback. I believe that the verify function is mandatory.
Hello,
It's my first time using this package and I dont clearly understand how to set the expire date on a token. I read the docs and I though it would be something like this:
But it doesn't seem to work properly.