node.js - 错误 400:invalid_request 缺少必需参数:范围
问题描述
从过去两天开始,我一直在这个问题上,一切都在我的本地环境中运行良好,但在生产中它给出了上述错误,
我的 Web 应用程序只能通过 vpn 访问,所以你认为这可能是问题吗?
router.get('/google', passport.authenticate('google', {
scope: ['openid','profile', 'email']
}));
我为点击和尝试方法添加的openid,但这也不起作用,以前在范围内只有电子邮件和个人资料在那里,我的谷歌startegy在下面
passport.use(
new GoogleStrategy({
// options for strategy
callbackURL: `${baseUrl}/auth/google/redirect`,
clientID: process.env.PASSPORT_CLIENT_ID,
clientSecret: process.env.PASSPORT_CLIENTSECRET
}, (accessToken: string, refreshToken: string, profile: any, done: any) => {
//code
})
我正在使用 passport-google-oauth20 npm 包进行谷歌登录,任何帮助将不胜感激
解决方案
尝试改变这个:
router.get('/google', passport.authenticate('google', {
scope: ['openid','profile', 'email']
}));
为了这:
app.get('/auth/google', passport.authenticate('google', {
scope: ['openid','profile', 'email'] }));
它对我有用...
推荐阅读
- json - 从此 JSON 创建数据库表
- function - 在方案中显示和返回某些内容的程序?
- php - 如何使代码下的变量成为全局变量并在 php 中为上面的代码工作?
- django - 在另一个列表 jinja 中搜索对象
- python - 为什么 scipy.interpolate.griddata 表现不佳?
- entity-framework-core - 仅更新 EF Core 中的一个字段
- node.js - 无法启动 webpack-dev-server - 未找到模块
- python - 子类化 argparse.ArgumentParser 正在产生奇怪的行为
- mysql - 查询两个不同的表而不重复
- python - 如何比较两个确切的展示位置列表?