mikenicholson / passport-jwt

Passport authentication using JSON Web Tokens
MIT License
1.96k stars 213 forks source link

ExtractJwt.fromUrlQueryParameter('token') not working need solution--PLZ NEED HELP #144

Closed jmandivarapu1 closed 5 years ago

jmandivarapu1 commented 6 years ago

I need help regarding as i struck at this point.there is no other option for me otherthan extracting the token from the URL.

my requested url is http://localhost:3000/api/deal?token=JWTeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ93KktUvltKS4h89Oyv5LMKYwiBP3GvU8

let opts = {};
opts.jwtFromRequest =  ExtractJwt.fromUrlQueryParameter('token')
opts.secretOrKey = config.secret;
 passport.use(new JwtStrategy(opts, function(jwt_payload, done) {
      const jwt_user_id = jwt_payload._doc._id
      User.findById(jwt_user_id, function(err, user) {
        if (err) {
          return done(err, false);
        }
        if (user) {
          done(null, user);
        } else {
          done(null, false);
        }
      });
    })); 
mikenicholson commented 6 years ago

There is not enough information for me to help. Can you provide a simplified app.js and package.json that reproduces the issue.

mikenicholson commented 5 years ago

Closing, no response.