【问题标题】:Passport is authenticating strategies more than once (using multistrategies)Passport 不止一次地验证策略(使用多重策略)
【发布时间】:2015-03-18 15:41:20
【问题描述】:

我已将 Passport.js 配置为使用多种策略:

passport.authenticate(['bearer', 'facebook-token', 'google-token', 'linkedin-token'],function(err, user, info) ...

我确信这个身份验证函数只调用一次,但在 Passport 的源代码中的 authenticate.js 文件中,我看到一些策略执行了多次。

假设承载失败,那么我想尝试 facebook-token。

我的 facebookTokenStrategy 代码如下:

facebookTokenStrategy: new FacebookTokenStrategy({
    clientID: process.env.FACEBOOK_APP_ID,
    clientSecret: process.env.FACEBOOK_APP_SECRET
}, function(access_token, refresh_token, profile, done) {
    someFunction().then(function(user) {
        return done(null, user)
    }, done)
}),

我已在其中许多点放置控制台日志并检查 facebook-token 策略是否适用于正确的访问令牌,但该策略多次“成功”,并且我对 Node.js 的 API 调用最终显示“无法获取 /api/authenticate”。

【问题讨论】:

    标签: javascript node.js express passport.js


    【解决方案1】:

    我的错。在承载策略中调用了 done() 两次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 2014-04-10
      • 2015-01-03
      • 1970-01-01
      • 1970-01-01
      • 2018-05-09
      • 2023-04-05
      相关资源
      最近更新 更多