-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"expiresIn" doesn't work with string or number #153
Comments
I should have read the documentation better:
I was sending in a string. Closing as non-issue. |
After updating to 5.5, I started seeing this error, whereas I wasn't seeing it before. I am also passing a string in rather than an object literal, so I went ahead and removed the expiration since it's not being used and it cleared the error up. However, this error message is incorrect - the format of "expiresIn" was correct, so this is an open bug in my opinion. |
Please re-open |
Notice that it will be silently ignored now when the payload doesn't support expiration. I plan to fail explicitly in the next major version. |
Out of nowhere I'm facing exact same issue. First it was working fine and now its giving me this error
|
@MeRahulAhire |
Facing the same issue |
@nayabahmad You can check https://www.npmjs.com/package/jsonwebtoken the Token Expiration (exp claim) part. |
Just make the payload an object: |
That solved the problem. Thank you |
The type of payload to sign should be: ref: https://github.com/auth0/node-jsonwebtoken/blob/master/sign.js#L90 |
You can only set expiresIn when that payload is an object. Ref: https://community.auth0.com/t/i-need-some-help-with-jwt-expiresin-syntax/47333 |
Getting the error
"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60
I looked at where the error was being thrown in index.js line 86:
payload.exp = timespan(options.expiresIn);
I stepped through the timespan function and everything looks good there if I pass in either string or number. However the function always returns undefined?
The text was updated successfully, but these errors were encountered: