使用passport-google-oauth20实现谷歌登录生产环境缺scope报错,是否与VPN有关
生产环境Google登录异常排查
异常概况
- 该问题已持续近2天,排查过程无明显进展
- 本地开发环境所有功能运行正常
- 生产环境部署完成后,触发Google登录流程时直接抛出错误:
Error 400: invalid_request Missing required parameter: scope - 待验证疑问:当前Web应用仅支持VPN访问,怀疑该网络特性可能是异常产生的原因
代码配置
Google登录跳转路由
router.get('/google', passport.authenticate('google', { scope: ['openid','profile', 'email'] }));
GoogleStrategy 初始化配置
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 }) );
已开展的排查动作
- 初始版本的scope配置仅包含
email、profile两个授权范围 - 为定位问题,临时在scope数组中新增
openid参数,重新部署后异常仍未解决
技术实现说明
- 基于
passport-google-oauth20npm包封装实现Google登录能力 - 寻求社区技术协助,定位该生产环境专属异常的根本成因
内容的提问来源于stack exchange,提问作者Farman Ali
相关产品推荐
相关产品推荐

