“此应用程序希望:具有离线访问权限"当access_type = online时 [英] "This app would like to: Have offline access" when access_type=online

查看:116
本文介绍了“此应用程序希望:具有离线访问权限"当access_type = online时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有OAuth 2.0身份验证的Google App.一切正常,但最近我开始显示以下请求许可"屏幕:

I have a Google App with OAuth 2.0 authentication. Everything used to work fine but recently I started getting the following "Request for permission" screen:

奇怪的是,当我通过access_type=online时,我得到了这个屏幕.同样,它一直可以使用到最近.

The strange part is that I get this screen when I pass access_type=online. Again, this used to work until recently.

这可能是什么原因? TIA

What can be the cause for this? TIA

请求的范围是:

https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile

我已经尝试过:

  • 有和没有access_type=online
  • 有和没有approval_prompt=auto
  • with and without access_type=online
  • with and without approval_prompt=auto

编辑#2:

这是我用来生成身份验证URL的python代码:

This is the python code I'm using to generate the authentication URL:

encoded_params = urllib.urlencode({
    "response_type" : "code",
    "client_id" : MY_CLIENT_ID,
    "scope" : " ".join(MY_SCOPES),
    "redirect_uri" : MY_REDIRECT_URI,
    "state" : random_security_token,
    "access_type" : "online",
    "approval_prompt" : "auto",
    })

auth_url = "https://accounts.google.com/o/oauth2/auth?" + encoded_params

更新(10月14日):

即使有了新的作用域,我仍然会看到同意屏幕.最近,我在用于身份验证的新设备上得到了它.

Even with the new scopes, I still get the consent screen. Recently I got it for a new device I was using for the authentication.

推荐答案

我认为,当您的应用请求令牌并且对于所涉及的范围用户仍然有有效的访问或刷新令牌时,G会执行此操作.

I think G does this when your app requests a token and there is still a valid access or refresh token for the user for the scopes in question.

解决方案是在发出令牌后(在用户注销时或在验证用户身份后立即)撤消令牌:

The solution is to revoke tokens when you're done with them (either on user logout or immediately after authenticating the user) by issuing this request:

https://accounts.google.com/o/oauth2/revoke?token={token}

您不必提供任何应用程序凭据,只需将令牌作为URL参数即可.

You don't have to provide any app credentials, just the token as a URL argument.

(此处的文档 https://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevoke)

我遇到了同样的问题,似乎没有任何access_typeapproval_prompt值的组合可以解决.撤销令牌可以解决问题.

I had the same problem and no combination of access_type or approval_prompt values seemed to solve it. Revoking the token did the trick.

我不确定如何撤销应用程序的所有未完成令牌,除非您碰巧存储了它们.要使用您自己的用户帐户进行测试,您可以在此处手动撤消应用程序的现有令牌:

I'm not sure how to revoke all outstanding tokens for your app, unless you happened to store them. To test with your own user account, you can manually revoke the existing token for your app here:

https://security.google.com/settings/security/permissions

这篇关于“此应用程序希望:具有离线访问权限"当access_type = online时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆