oauth-2.0 - 无法再获取 OAuth2 访问 token : invalid_scope error

标签 oauth-2.0 google-api google-oauth

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

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

我关注了 the documentation来实现这一点。

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

检索授权码的 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');

用于交换访问 token 的授权码的 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#]}"

同样,几个月来我已经能够使用相同的代码检索访问 token 和刷新 token 。

截至 2018 年 9 月 12 日,此错误突然出现。

我的代码没有任何变化。

有没有人对我现在收到此错误的原因有任何想法?

最佳答案

删除电子邮件范围怎么样?

我猜谷歌现在已经修复了它。我现在可以在我的应用程序上登录而不删除电子邮件范围。

关于oauth-2.0 - 无法再获取 OAuth2 访问 token : invalid_scope error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52319770/

相关文章:

asp.net - 使用 asp.net 4.5 OAuth 用 clientid 和 secret 注册谷歌

android - 使用 Google API 创建 Google 应用内产品

gdata - 电子表格列表 Gdata OAuth2

google-api - 使用具有 Java 和 Oauth 身份验证的 Gmail API 发送自动电子邮件

php - 如何在 PHP 中获取 OAuth 2.0 token ?

azure - 基于范围/角色/组的访问控制

IOS - Linkedin 将 oauth2.0 与 google oauth 库集成 - 出现 404 错误(找不到页面)

java - 将客户电子邮件列表上传到 Google Ads Management API

javascript - 使用 API 和 JavaScript 写入工作表 - CORS block

node.js - 访问 token 过期后的 Google API 无效请求