Missing request parameter in JwtStrategy verify function documentation
See original GitHub issueWhen first implementing the sample code I was getting an error that ‘jwt_payload.sub’ was undefined. Looking a little closer I discovered that the verify function takes 3 args - the request, the payload, and callback. So:
passport.use(new JwtStrategy(opts, function(jwt_payload, done) {
Should be
passport.use(new JwtStrategy(opts, function(req, jwt_payload, done) {
Issue Analytics
- State:
- Created 8 years ago
- Comments:7
Top Results From Across the Web
Passport JWT Strategy not getting called - node.js
I am trying to authorise my JWT token with passport middleware but the strategy callback function is not getting called.
Read more >Everything you need to know about the `passport-jwt ... - Medium
The Passport JWT strategy uses the jsonwebtoken library. Why is this important?? Remember–JWTs need to first be signed and then verified.
Read more >Passport JWT Strategy Configuration (Node + ... - YouTube
This video is part of the Passport JS User Authentication Series. To view the entire series as a playlist, click the link ...
Read more >The Ultimate Guide to Passport JS - DEV Community
Find the request that has "document" as the "Type" value and click on it. ... it to verify later (similar to what we...
Read more >How to use the passport-jwt.Strategy function in ... - Snyk
To help you get started, we've selected a few passport-jwt.Strategy examples, based on ... const KEY = 'test-key'; async function userFromPayload(request, ...
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
The passport.use() will automatically run when you call the passport.authenticate(‘jwt’, cb). You should pass the authorization in header with valid JWT signed(
user
) token. If it valid and non-expired token thenpayload.sub
will haveuser
otherwise it doesnt contain user.You need to
opts.passReqToCallback
totrue
to get the request as a parameter. Otherwise the callback will receive only payload and done.