【问题标题】:Access to req object in success callback在成功回调中访问 req 对象
【发布时间】:2013-11-01 11:38:09
【问题描述】:

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

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

【问题讨论】:

  • 什么req 对象?它的范围是什么? (因为您提供的代码中没有它)

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


【解决方案1】:

好的,找到答案了。需要在options中设置passReqToCallback: true,那么回调的第一个参数就是req对象:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 1970-01-01
    • 1970-01-01
    • 2018-01-06
    • 2012-06-12
    相关资源
    最近更新 更多