You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Electron+React集成@react-oauth/google登录遇来源不被允许问题求助

React + Electron 集成 @react-oauth/google 实现Google登录失败问题

我刚接触React及客户端开发,正在基于React构建Electron应用,目前基础功能运行正常。

现在想集成@react-oauth/google,让用户通过Google账号登录以授权应用访问Google Drive,但遇到了问题(相关代码在仓库的testing_auth_2分支)。

已完成的操作:

  • 在GCP中启用Drive API;
  • 创建Web应用凭证,添加http://localhost和http://localhost:3000作为授权JavaScript来源;
  • 尝试创建Desktop和iOS类型的凭证(无需设置授权来源),但错误仍存在。

当前现象:网页模式下执行npm start,Google登录功能正常;以Electron应用模式启动(执行npm run electron:dev)时登录失败,推测是Electron运行环境并非localhost导致。

复现步骤:

  • 在GCP中启用Drive API并创建对应凭证;
  • 克隆仓库:git@github.com:Urr4/electron-archive.git;
  • 切换分支:git checkout testing_auth_2;
  • 将index.tsx中的XXX替换为实际的client_id;
  • 执行npm start,验证网页模式登录正常;
  • 执行npm run electron:dev,验证Electron模式登录失败。

内容的提问来源于stack exchange,提问作者Urr4

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 01:57:37