以下是我收到的错误:
TokenError: Bad Request
at Strategy.OAuth2Strategy.parseErrorResponse (/home/ubuntu/workspace/React/fullstack-basics/node_modules/passport-oauth2/lib/strategy.js:329:12)
at Strategy.OAuth2Strategy._createOAuthError (/home/ubuntu/workspace/React/fullstack-basics/node_modules/passport-oauth2/lib/strategy.js:376:16)
at /home/ubuntu/workspace/React/fullstack-basics/node_modules/passport-oauth2/lib/strategy.js:166:45
at /home/ubuntu/workspace/React/fullstack-basics/node_modules/oauth/lib/oauth2.js:191:18
at passBackControl (/home/ubuntu/workspace/React/fullstack-basics/node_modules/oauth/lib/oauth2.js:132:9)
at IncomingMessage.<anonymous> (/home/ubuntu/workspace/React/fullstack-basics/node_modules/oauth/lib/oauth2.js:157:7)
at emitNone (events.js:120:20)
at IncomingMessage.emit (events.js:218:7)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
这是我的index.js:
const express = require('express'),
passport = require('passport'),
GoogleStrategy = require('passport-google-oauth20').Strategy,
keys = require('./config/keys');
const app = express();
app.use(express.static('public'));
app.set('view engine', 'ejs');
passport.use(
new GoogleStrategy(
{
clientID: keys.googleClientID,
clientSecret: keys.googleClientSecret,
callbackURL: '/auth/google/callback'
},
accessToken => {
console.log(accessToken);
}
)
);
app.get('/', (req, res) => {
res.render('index');
});
app.get('/auth/google',
passport.authenticate('google', {
scope: ['profile', 'email']
})
);
app.get('/auth/google/callback', passport.authenticate('google'));
const PORT = process.env.PORT || 8080;
app.listen(PORT, process.env.IP, () => {
console.log('Server is listening..');
});
我正在使用C9 我在API应用设置中的设置如下:
授权的JavaScript来源 - &gt; http://learning-space-fvrthebrave.c9users.io 授权重定向URI - &gt; http://learning-space-fvrthebrave.c9users.io/auth/google/callback
我被困在这里,无法判断我的代码是否存在问题或oauth存在问题!