我尝试使用护照在我的 express API 中实现 google OAuth2,但出现错误:
---------------------------------------------路由文件
:users.js
...
const GoogleStrategy = require('passport-google-oauth20').Strategy
...
passport.use(new GoogleStrategy(
{
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: 'users/auth/google/callback'
}, accessToken => {
console.log(accessToken);
}
)
)
...
router.get('/auth/google', passport.authenticate('google', {scope: ['profile', 'email']}))
...
在 Google 开发人员控制台中,我将授权重定向 URI 设置为:
http://localhost:3000/users/auth/google/callback 我的客户端 ID 和密码是正确的。
在错误消息中,我可以看到重定向 URI 是:http://localhost:3000/auth/users/auth/google/callback
Url路径的开头有一个额外auth
的,奇怪的是我没有设置它。我怎样才能删除它?我什至可以删除它吗?