为什么在使用Passport / Node Express的OAuth2Strategy进行身份validation时遇到TokenError?

我试图与Express(4)一起使用Passport JS的OAuth2Strategy。

我redirect到login后,它成功导航回到我的callbackurl,在这一点上,我得到以下错误:

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) 

我的护照configuration如下:

 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"); }); 

任何帮助/build议将不胜感激!

       

网上收集的解决方案 "为什么在使用Passport / Node Express的OAuth2Strategy进行身份validation时遇到TokenError?"