离线时没有刷新令牌/访问数据的权限(google-oauth) [英] No refresh token / permission to access data while offline (google-oauth)

查看:82
本文介绍了离线时没有刷新令牌/访问数据的权限(google-oauth)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此处的文档:

https://developers.google.com/accounts/docs/OAuth2WebServer#offline

在查询字符串中具有access_type = offline的请求应授予用户脱机时访问数据的权限,并导致Google在用户接受时发送刷新令牌.从几天前开始不再发生这种情况.有谁知道发生了什么变化,或者是否有更好的方法来获取访问/刷新令牌?

Requests with access_type=offline in the querystring should grant a permission to access data while the user is offline and result in google sending a refresh token when the user accepts. This is no longer happening as of a few days ago. Does anyone know what changed or if there is a better way to go about getting an access/refresh token?

很显然,如果您要链接的帐户已经授予了权限,则可能会发生这种情况(在这种情况下,您需要先撤消该Google帐户的权限,然后再试一次).在我们的情况下,即使撤消了权限,这种情况仍在发生.

Apparently this can occur if the account you are trying to link has already granted the permissions (in which case you need to revoke the permissions on that google account before trying again). In our case it is happening even with revoked permissions.

推荐答案

如果您要求脱机访问并且仍未获得刷新令牌,则意味着该特定用户已经发出了刷新令牌,并且授权请求已自动得到正式认可的.请参阅重要"块.

If you are asking offline access and still not getting a refresh token that means that for that particular user a refresh token was already issued and the authorization request was auto-approved. See the "Important" block.

可能为该给定用户发行了多个刷新令牌,您如何撤消权限?

It is possible that there are multiple refresh tokens issued for that given user, how did you revoke permissions?

为了从这种情况中恢复,您必须通过在请求中添加提示=无来抑制自动批准(approval_prompt = force是旧方法): https://developers.google.com/accounts/docs/OAuth2Login#authenticationuriparameters

In order to recover from this situation you have to suppress auto-approval by adding prompt=none to the request (approval_prompt=force is the old way): https://developers.google.com/accounts/docs/OAuth2Login#authenticationuriparameters

确保仅在这些特殊情况下才禁止自动批准.

Make sure you suppress auto-approval only in these corner cases.

这篇关于离线时没有刷新令牌/访问数据的权限(google-oauth)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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