2014-09-22 36 views
2

我正在嘗試使用PingFederate作爲我的身份驗證服務器和passport-ping npm登錄。不工作:PingFederate + Passport.js Ping

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

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賦予權限和重定向從那裏精細發生。但是,當護照嘗試解析此授權碼時,會出現以下錯誤:

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) 

有人可以幫我解決嗎?我錯過了什麼嗎?

回答

0

它不是Passport未能解析響應,而是PingFederate授權服務器返回錯誤響應;你應該檢查你使用的client_id/client_secret是否與PingFederate中配置的內容相對應; FWIW:clientSecret: config.facebook.clientSecret對我來說似乎對我來說是一個用來防止PingFederate的祕密......