在成功回调中访问req对象

时间:2013-11-01 11:38:09

标签: node.js express passport.js passport-twitter

我需要在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
  }
));

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

1 个答案:

答案 0 :(得分:1)

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

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