始终“具有离线访问权限" | Google OAuth 2 [英] Always "Have Offline Access" | Google OAuth 2

查看:128
本文介绍了始终“具有离线访问权限" | Google OAuth 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google OAuth2 API获取用户的个人资料.经过用户身份验证后,在同意页面上,总是会要求我输入具有脱机访问权限"

I am trying to get fetch user's profile using Google OAuth2 api. After user authentication, on the consent page, I am always asked for "Have Offline Access"

浏览器中的URL看起来像:-

The URL in browser looks like :-

https://accounts.google.com/o/oauth2/auth ? scope = email & response_type = code& redirect_uri = 在上面的URL中可见,我已将范围参数传递为" 电子邮件 "

As visible in the URL above, I have passed scope parameter as 'email'

Google Auth API 页面说:-

此范围要求您的应用有权访问:

"This scope requests that your app be given access to:

用户的Google帐户电子邮件地址.您访问电子邮件地址 通过调用people.get,它返回电子邮件数组(或通过调用 people.getOpenIdConnect,它在以下位置返回电子邮件属性 符合OIDC的格式). Google Apps域的名称(如果有), 用户所属的.域名作为域名返回 来自people.get的属性(或来自getOpenIdConnect的hd属性).这 电子邮件范围等同于并替换 https://www.googleapis.com/auth/userinfo.email 范围."

the user's Google account email address. You access the email address by calling people.get, which returns the emails array (or by calling people.getOpenIdConnect, which returns the email property in OIDC-compliant format). the name of the Google Apps domain, if any, that the user belongs to. The domain name is returned as the domain property from people.get (or hd property from getOpenIdConnect). This email scope is equivalent to and replaces the https://www.googleapis.com/auth/userinfo.email scope."

为什么每次都要求我进行脱机访问?

Why I am asked for Offline Access every time?

推荐答案

我遇到了同样的问题,在谷歌搜索了很长时间之后,我找到了以下链接:

I had the same problem, and after googling for a long while, I found this link:

"此应用会希望:具有离线访问权限"当access_type = online

它建议删除redirect_uri中的"localhost",它对我有用.

it suggests to remove 'localhost' in the redirect_uri, and it works for me.

这篇关于始终“具有离线访问权限" | Google OAuth 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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