You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had implemented passport-http-bearer for authentication and upon token expiry i need to send token expired message from my rest api.For that I throw a message from BearerStrategy .But from the library it throws only 'Unauthorized' message.
`passport.use(new BearerStrategy(
function(accessToken, done) {
And the api route is app.get(version+'/grids',passport.authenticate('bearer', { session: false }),gridsController.list);
How to get the token expired message instead of 'Unauthorized' message
The text was updated successfully, but these errors were encountered:
Have you verified the "Token expired" branch is run?
I'd dive in deeper if you could provide a minimal runnable example (maybe as a gist).
Another minor performance hint: I'd calculate the token expiration date in milliseconds, save that, and then just compare it to Date.now() in each check, since the check operation is probably performed lots more times.
Update:
from the library it throws only 'Unauthorized' message.
I guess you mean the "HTTP/1.1 401 Unauthorized" status code? That's a standardized part of the protocol. The place for custom messages would be in the error response body, which might be generated by later middleware using the data in req.authInfo.
You could also try providing a custom error as the first arument to done.
I had implemented passport-http-bearer for authentication and upon token expiry i need to send token expired message from my rest api.For that I throw a message from BearerStrategy .But from the library it throws only 'Unauthorized' message.
`passport.use(new BearerStrategy(
function(accessToken, done) {
And the api route is
app.get(version+'/grids',passport.authenticate('bearer', { session: false }),gridsController.list);
How to get the token expired message instead of 'Unauthorized' message
The text was updated successfully, but these errors were encountered: