Providing custom message when failed to extract token
See original GitHub issueAre there any support for this ?
passport.use('jwt', new JwtStrategy({
secretOrKey: authConfig.secret,
jwtFromRequest: ExtractJwt.fromAuthHeader(), //If return null, finishes with empty message
algorithms: authConfig.algorithms
},
function(jwt_payload, done) {
//Never had the chance to call done with custom message
Account.findById(jwt_payload.userId, function(err, account) {
if (err) return done(err);
if (!account) return done(null, false, 'invalid Token');
return done(null, account, 'valid Token');
});
})
);
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Best practices for API error handling and troubleshooting
The table below provides details about the main error cases that your application could meet. Missing credentials: e.g. missing Authorization ...
Read more >Custom Error Messages with Mongoose - Stack Overflow
So I wanted to do something similar: var emailVerificationTokenSchema = mongoose. Schema({ email: {type: String, required: true, unique: [true, ...
Read more >How to Customize and Validate the Json Message for ...
This use case describes how to customize and validates JSON message for GrantType client credential – AccessToken.
Read more >Decode JWT runtime error troubleshooting | Apigee Edge
This error occurs if the JSON Web Token (JWT) specified in the <Source> element of the Decode JWT policy is malformed, invalid or...
Read more >Access Token Response - OAuth 2.0 Simplified
invalid_grant – The authorization code (or user's password for the password grant type) is invalid or expired. This is also the error you...
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 FreeTop 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
Top GitHub Comments
You can check for Error string in info to catch and provide custom messages.
Manteiners should add this “info” param and examples to the http://www.passportjs.org/packages/passport-jwt/ docs. I could’t find the error until i read this issue. Thanks