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

标签 authentication oauth go google-api google-oauth

问题是 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/

相关文章:

ios - 操作无法完成

使用标准库的好示例 Go 代码

javascript - 我的 sails.js Passport.js 实现中出现 InternalOAuthError 的原因是什么?

ruby-on-rails - Ruby on Rails - 通过 IP 限制点击

ios - session 身份验证 token Swift

Powershell 和 Jenkins - 以另一个用户身份执行 Powershell 脚本

mongodb - 在不实现自定义身份验证方案或解析 token 的情况下从 token header 中删除 "Bearer"?

Android OAuth 2.O 无法检索访问 token

go - 带有 %e 错误的字符串格式

arrays - 语法错误 : unexpected semicolon or newline, 期待 }