不再能够获取OAuth2访问令牌:invalid_scope错误

时间:2018-09-13 18:28:02

标签: oauth-2.0 google-api google-oauth google-oauth2

我已经使用React Native Framework编写了一个移动应用程序。

该应用程序使用Google的OAuth 2.0端点来授权对Google API的访问。

我遵循the documentation来实现这一点。

几个月来,通过发出以下HTTP请求,我已经能够检索访问令牌和刷新令牌:

用于获取授权码的HTTP GET请求:

https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile%20https://www.googleapis.com/auth/youtube%20https://www.googleapis.com/auth/yt-analytics.readonly%20https://www.googleapis.com/auth/yt-analytics-monetary.readonly%20https://www.googleapis.com/auth/youtubepartner&response_type=code&client_id=OMITTED&redirect_uri=OMITTED');

HTTP POST请求以交换访问令牌的授权代码:

let queryString = "code=" + authCode + "&" + "client_id=OMITTED&redirect_uri=OMITTED&grant_type=authorization_code";

fetch('https://www.googleapis.com/oauth2/v4/token', {method:'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }, body: queryString})

此POST请求现在在响应中出现以下错误:

错误:

"invalid_scope"
error_description
:
"Some requested scopes were invalid. {valid=[https://www.googleapis.com/auth/userinfo.email, https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/youtube, https://www.googleapis.com/auth/yt-analytics.readonly, https://www.googleapis.com/auth/yt-analytics-monetary.readonly], invalid=[https://www.googleapis.com/auth/youtubepartner#]}"

再次,使用相同的代码,我已经能够检索访问令牌和刷新令牌几个月了。

从2018年12月12日起,此错误突然浮出水面。

我的代码没有更改。

有人对我为什么现在遇到此错误有任何想法吗?

1 个答案:

答案 0 :(得分:0)

如何删除电子邮件范围?


我想Google已经修复了它。我现在无需在应用程序上删除电子邮件范围即可登录。

相关问题