Access to req object in success callback

时间:2022-06-12 03:50:22

I need to get access to req object in success callback of Twitter Passport:

我需要在Twitter Passport的成功回调中访问req对象:

passport.use(new TwitterStrategy({
    consumerKey: TWITTER_CONSUMER_KEY,
    consumerSecret: TWITTER_CONSUMER_SECRET,
    callbackURL: "http://127.0.0.1:3000/auth/twitter/callback"
  },
  function(token, tokenSecret, profile, done) {
    //here I need `req` object
  }
));

How can I access to that in success callback scope?

如何在成功回调范围内访问?

1 个解决方案

#1


1  

Ok, found the answer. You need to set passReqToCallback: true in options, then the first parameter of callback will be req object:

好的,找到了答案。你需要在选项中设置passReqToCallback:true,然后回调的第一个参数将是req对象:

https://github.com/jaredhanson/passport/issues/39

#1


1  

Ok, found the answer. You need to set passReqToCallback: true in options, then the first parameter of callback will be req object:

好的,找到了答案。你需要在选项中设置passReqToCallback:true,然后回调的第一个参数将是req对象:

https://github.com/jaredhanson/passport/issues/39