【问题标题】:Google Drive API: Cannot update file labels on a read-only folderGoogle Drive API:无法更新只读文件夹上的文件标签
【发布时间】:2013-08-08 22:58:01
【问题描述】:

我有两个用户:admin@example.com(“管理员”)和 user@example.com(“用户”)。

“Admin”拥有一个 Google Drive 文件夹(假设该文件夹的 fileId 是“F1234”)。 “用户”是对文件夹具有只读(“查看者”)访问权限的 Google 群组的成员。

在 Google Drive Web 界面中,“用户”可以打开文件夹 F1234,“用户”可以点击“星标”按钮将该文件夹放入“已加星标”列表。到目前为止,一切顺利。

现在我想编写一个将文件夹设置为星号的应用程序。因此,我以“用户”身份登录,然后转到 Google Drive API Explorer (https://developers.google.com/drive/v2/reference/files/patch),并为 API 浏览器提供 OAuth 令牌以代表“用户”执行请求。我发送“补丁”请求将文件夹设置为“已加星标”:

PATCH https://www.googleapis.com/drive/v2/files/F1234?fields=labels%2Fstarred&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer xxxxxxxxxxxxxxxxxxxxxxxxxx
X-JavaScript-User-Agent:  Google APIs Explorer

{
  "labels": {
    "starred": true
  }
}

但此请求失败,出现“权限被拒绝”类型的错误:

403 Forbidden

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "userAccess",
    "message": "The authenticated user does not have the required access to the file F1234",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 403,
  "message": "The authenticated user does not have the required access to the file F1234"
 }
}

我检查了同样的请求是否适用于“用户”拥有的文件夹,或不属于用户但“用户”具有读写访问权限的文件夹。所以看起来请求失败是因为只读权限,但这与 UI 的行为不一致(“加星标”文件不是修改,所以它不应该需要写访问权限)。

是我遗漏了什么还是 Google Drive API 错误?

【问题讨论】:

    标签: google-drive-api


    【解决方案1】:

    此行为已被复制。 我会为你报告这件事。 给您带来不便,敬请见谅。

    【讨论】:

      猜你喜欢
      • 2012-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多