gpt4 book ai didi

Electron 应用程序有时会尝试使用旧版 Oauth 路由登录用户

转载 作者:行者123 更新时间:2023-12-02 00:49:52 25 4
gpt4 key购买 nike

我们有一个多平台应用程序(Web、桌面版 Electron、iOS 和 Android 应用程序)。通过我们的 Electron 应用程序进行身份验证时,我们的一些用户被转发到旧的身份验证路由( https://accounts.google.com/signin/oauth/legacy/approval ) 而不是标准的身份验证路由 ( https://accounts.google.com/signin/oauth/consent/approval )。此旧版身份验证路由无法完成授权,因此我们的用户无法登录到我们的应用程序。只有我们的 Electron 用户才能看到这一点。我们第一次看到这种情况是在 10 月 16 日,10 月 28 日左右变得更加频繁。

当我们打开 Electron 浏览器窗口并访问时会发生这种情况 https://accounts.google.com/o/oauth2/v2/auth与标准参数。如果我们将相同的 URL 和参数复制到非 Electron 浏览器窗口中,我们将被发送到标准身份验证路由。

这是我们的 Electron Oauth 代码的相关部分:

      const authParams = {
access_type: opts.offline ? 'offline' : undefined,
response_type: 'code id_token',
redirect_uri: 'http://localhost/authenticate',
scope: expandedScopes.join(' '),
client_id: xxxx,
prompt: 'consent',
login_hint: opts.email ? opts.email : undefined,
nonce
}

const authParamStr = queryStringify(authParams)
const authUrl = `https://accounts.google.com/o/oauth2/v2/auth?${authParamStr}`
authWindow.loadURL(authUrl)

发生的情况是,Oauth 同意流程的最后一个屏幕没有经过正确的身份验证,而是一个标题为“Approved Clicked”的白色屏幕。在 Web 和其他平台上,登录正确完成。

最佳答案

我们通过简单地从用户代理中剥离 Electron 来解决这个问题。在您的情况下,它可能是这样的。

authWindow.loadURL(authUrl, {
userAgent: navigator.userAgent.replace(/ Electron\/\S+ /g, ' ');
});

没有解释 Google 这样做的原因,但同时绕过了它。

关于Electron 应用程序有时会尝试使用旧版 Oauth 路由登录用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58717065/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com