【问题标题】:error to use "https://www.googleapis.com/auth/drive" scope使用“https://www.googleapis.com/auth/drive”范围时出错
【发布时间】:2013-03-08 09:09:00
【问题描述】:

google-api-java-client 版本: google-api-1.13.2-beta.jar Java 环境: Java 6

描述问题。

我有一个问题。 我想使用 OAuth 2.0 for Devices 访问 Google Drive。 使用"https://www.googleapis.com/auth/drive" 范围是错误的。 当您在范围内使用 "https://docs.google.com/feeds/" 时,我成功了。 我想知道我是否使用"https://docs.google.com/feeds/" 来使用“DriveAPI”我。 这是正确的用法吗?

请求:

POST https://accounts.google.com/o/oauth2/device/code HTTP/1.1

client_id=xxxxx.apps.googleusercontent.com&scope=https://www.googleapis.com/auth/drive

Response: {   "error" : "invalid_scope" }

回应:

POST https://accounts.google.com/o/oauth2/device/code HTTP/1.1

client_id=xxxxx.apps.googleusercontent.com&scope=https://docs.google.com/feeds/

Response:
{
  "device_code" : "4/e6HcZHKPz-eExgLb_Ll9V8qoT1NP",
  "user_code" : "zzwiv48b",
  "verification_url" : "http://www.google.com/device",
  "expires_in" : 1800,
  "interval" : 5
}

您希望它如何解决? 我认为可以在“https://www.googleapis.com/auth/drive”I的范围内进行身份验证。

developers.google.com

stackoverflow.com

【问题讨论】:

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


    【解决方案1】:

    您在协议中缺少一个 h。尝试 https://docs.google.com/feeds/ 而不是 ttps://docs.google.com/feeds/。对所有范围 URL 应用相同的更改

    【讨论】:

    • 谢谢。我被设置为“ttps://”,因为它无法在“https://”的公告板上发布。事实上,我一直在使用“https://”。
    【解决方案2】:

    来自有关“将 OAuth 2.0 用于设备”的 Google 文档 (https://developers.google.com/identity/protocols/OAuth2ForDevices#allowedscopes):

    当您对设备使用 OAuth 2.0 流程时,您只能访问以下范围:

    • 分析配置和报告 API
    • 日历 API
    • 联系人 API
    • 云打印 API
    • 云存储 API
    • 健身 REST API
    • 融合表 API
    • 谷歌登录
    • YouTube 数据和直播 API

    我在此列表中没有看到 Drive API,我认为这是“invalid_scope”错误的原因

    【讨论】:

      【解决方案3】:

      我也有同样的问题。 我已按照开发文档中的说明进行操作,并在请求中使用 "www.googleapis.com/auth/drive" 作为我的范围。 最终,我在响应中得到了“invalid_scope”。

      所以我尝试使用 "www.googleapis.com/auth/devstorage.full_control" 作为范围,并且成功了!提示来自:https://cloud.google.com/storage/docs/authentication#oauth

      但是!!当我使用我创建的访问令牌列出 google drive 帐户信息时,我收到错误代码 403 并且消息是“权限不足”。

      这是我用来请求帐户信息的: curl -H "授权:承载 $ACCESS_TOKEN" https://www.googleapis.com/drive/v2/about?key=$APP_KEY

      这真的让我很困惑......

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-13
        • 1970-01-01
        • 2018-08-27
        • 2021-02-05
        • 1970-01-01
        • 2019-06-27
        • 1970-01-01
        相关资源
        最近更新 更多