`UnauthorizedError: jwt expired` being thrown with `credentialsRequired: false`
See original GitHub issueI believe that according to https://github.com/auth0/express-jwt/pull/47 I should not get this error?
UnauthorizedError: jwt expired
at /Users/me/gh/api-model/node_modules/express-jwt/lib/index.js:102:22
at /Users/me/gh/api-model/node_modules/jsonwebtoken/verify.js:27:18
Code:
import jwt from 'express-jwt'
expressApp.use(
'/graphql',
jwt({
...
credentialsRequired: false
}),
...
)
Version: "express-jwt": "^5.3.0",
Issue Analytics
- State:
- Created 5 years ago
- Reactions:20
- Comments:9
Top Results From Across the Web
I'm getting `UnauthorizedError: jwt malformed at new ...
If I understand this correctly, the way to do this is to add credentialsRequired: false as one of the params to the middleware....
Read more >JWT expired, unexpected response in nodejs API
Here is when i have the error, the middleware is failling to verify the user and throw me this error jwt expired. This...
Read more >jwt expired` being thrown with `credentialsRequired: false`
I believe that according to https://github.com/auth0/express-jwt/pull/47 I should not get this error? UnauthorizedError: jwt expired at ...
Read more >express-jwt - npm
ExpirationHandler (optional): A function to handle expired tokens. credentialsRequired?: boolean (optional): If its false, continue to the ...
Read more >Secure Access to your Node.js Graphql Server with JWT.
According to jwt.io (JWT Official website), JSON Web Token (JWT) is an ... the credentialsRequired option to false so Express won't throw an ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The behavior was changed, caught me by surprise to. When the token is invalid it will now go to the error handler even if {credentialsRequired: false} is set. It used to be that it just continued as an unauthenticated user.
You can go back to the previous behavior by eating the error like so:
@karellodewijk solution seems to work, but it’s weird to create custom error handlers while
credentialsRequired
is set tofalse
.