question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing request parameter in JwtStrategy verify function documentation

See original GitHub issue

When 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:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
devendra1102commented, Sep 30, 2016

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 then payload.subwill have user otherwise it doesnt contain user.

1reaction
roxeteercommented, Nov 11, 2015

You need to opts.passReqToCallback to true to get the request as a parameter. Otherwise the callback will receive only payload and done.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found