2

我正在尝试使用 PingFederate 作为我的身份验证服务器和passport-ping npm登录。

我做了所有常用的配置,即

app.get("/auth/ping", passport.authenticate("ping"));

app.get("/auth/ping/callback", 
    passport.authenticate("ping",{ failureRedirect: '/login'}),
    function(req,res){
        console.log(profile);
        res.render("profile", {user : req.user});
    }
);

  // Ping Strategy
  passport.use(new PingStrategy({
        host: 'blahblah.com',
        port: 9031,
        clientID: config.ping.clientID,
        clientSecret: config.facebook.clientSecret,
        callbackURL: config.ping.callbackURL
    },

  function(accessToken, refreshToken, profile, done) {
    User.findOrCreatePingUser(profile, done);
  }));

我什至可以从 PingFederate 获得许可,并且从那里进行重定向很好。但是,当 Passport 尝试解析此授权代码时,它会引发以下错误:

Express
500 TokenError: Invalid client or client credentials
at Strategy.OAuth2Strategy.parseErrorResponse (c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:298:12)
at Strategy.OAuth2Strategy._createOAuthError (c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:345:16)
at c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:171:43
at c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:177:18
at passBackControl (c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:124:9)
at IncomingMessage. (c:\Sandbox\node_modules\passport-ping\node_modules\passport-oauth\node_modules\passport-oauth2\node_modules\oauth\lib\oauth2.js:143:7)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)

有人可以帮帮我吗?我错过了什么吗?

4

1 回答 1

0

不是 Passport 解析响应失败,而是 PingFederate 授权服务器返回错误响应;您应该根据 PingFederate 中的配置检查您使用的 client_id/client_secret;FWIW:clientSecret: config.facebook.clientSecret对我来说似乎是用来对付 PingFederate 的秘密……

于 2014-12-22T09:26:53.383 回答