得到以下错误: GET / auth / provider / callback?code = E4wTTN 500 12.919 ms-1076 令牌错误 在OAuth2Strategy.parseErrorResponse(d:\ oAuth2 \ NodeJS \ express-oauth2-api \ node_modules \ passport-oauth2 \ lib \ strategy.js:358:12)
示例代码: PassportJS oAuth2 nodeJS + ExpresJS代码:
passport.use(new OAuth2Strategy({
authorizationURL: 'http://localhost:8888/implcitdemo/oauth/authorize',
tokenURL: 'http://localhost:8888/implcitdemo/oauth/token',
clientID: 'testClientID',
clientSecret: 'testClientSecret',
callbackURL: 'http://localhost:3000/auth/provider/callback'
},
function(accessToken, refreshToken, profile, cb) {
console.log(accessToken, refreshToken, profile.id, cb);
}
));
授权URL:
app.get('/auth/provider', passport.authenticate('oauth2'));
回调网址:
app.get('/auth/example/callback',
passport.authenticate('oauth2', { successRedirect: '/',
failureRedirect: '/login' }));
注意:我已经编写了自己的身份验证服务器,该服务器在localhost:8888上运行