我正在尝试使用PingFederate作为我的Auth Server和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)
有人可以帮我吗?我想念什么吗?
最佳答案
不是Passport无法解析响应,而是PingFederate授权服务器返回了错误响应。您应该对照PingFederate中配置的内容检查使用的client_id / client_secret; FWIW:clientSecret: config.facebook.clientSecret
在我看来,可作为对付PingFederate的秘密...
关于node.js - 无法正常运作:PingFederate + Passport.js Ping,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25967853/