gpt4 book ai didi

authentication - Google oauth2 在每次登录时显示批准提示

转载 作者:IT王子 更新时间:2023-10-29 01:48:16 25 4
gpt4 key购买 nike

问题是 oauth2 登录使用 https://github.com/golang/oauth2/ 无法正常工作图书馆。

Github 运行良好,在我批准后不会显示批准提示。但是 Google oauth2 会在每次登录时显示批准提示。

下面的url是golang oauth2生成的auth URL。我没有发现它的问题。

https://accounts.google.com/o/oauth2/auth?client_id=my_client_id&redirect_uri=redirect_url&response_type=code&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fplus.profile.emails.read&state=state

文档 ( https://developers.google.com/youtube/v3/guides/authentication ) 表示默认的 approval_prompt 值为自动。

我已经正确批准了 API 测试应用程序。并从权限页面(https://security.google.com/settings/security/permissions)确认

然后,https://accounts.google.com/o/oauth2/auth再次显示批准提示。我仔细检查过 approval_prompt 不是“强制”。

最佳答案

您可以将 token 缓存在文件中,并在应用程序启动时检查 token 是否仍然有效。如果 token 已过期,您只需要显示批准提示。

我就是这样做的。相关代码可见here .

关于authentication - Google oauth2 在每次登录时显示批准提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28408164/

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