Node.js 为什么在为Passport/Node Express使用OAuth2Strategy进行身份验证时出现令牌错误
我试图将Passport JS的OAuth2策略与Express(4)结合使用 在我被重定向到登录后,它成功地将我导航回回调url,此时我会收到以下错误:Node.js 为什么在为Passport/Node Express使用OAuth2Strategy进行身份验证时出现令牌错误,node.js,express,oauth,oauth-2.0,passport.js,Node.js,Express,Oauth,Oauth 2.0,Passport.js,我试图将Passport JS的OAuth2策略与Express(4)结合使用 在我被重定向到登录后,它成功地将我导航回回调url,此时我会收到以下错误: TokenError: Invalid client or client credentials at OAuth2Strategy.parseErrorResponse (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/l
TokenError: Invalid client or client credentials
at OAuth2Strategy.parseErrorResponse (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:298:12)
at OAuth2Strategy._createOAuthError (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:345:16)
at /www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:171:43
at /www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:177:18 at passBackControl (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:124:9)
at IncomingMessage.<anonymous> (/www/az-avatarz-server/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:143:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:919:16
at process._tickDomainCallback (node.js:463:13)
我的路线如下:
passport.use("avatarz", new OAuth2Strategy({
authorizationURL: authorizationURL,
tokenURL: tokenURL,
clientID: clientID,
clientSecret: clientSecret,
callbackURL: callbackURL
},
function (accessToken, refreshToken, profile, done) {
User.find({
prid: profile.prid
}, function (error, user) {
if (error) {
return done(error);
}
if (user) {
return done(null, user);
}
else {
done(error);
}
});
}
));
app.get('/authentication/provider', passport.authenticate("avatarz"));
app.get('/', passport.authenticate("avatarz", { failureRedirect: '/authentication/provider' }),
function (req, res) {
res.sendfile("./public/index.html");
});
如有任何帮助/建议,将不胜感激 确保您在以下位置激活了Google+API:当我错误地指定了客户端密码时,我出现了完全相同的症状。可能需要再次检查它是否与您位于的项目的客户机密相同。^上述问题也是我的问题!谢谢