1

我有两个用户: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 错误?

4

1 回答 1

0

此行为已被重现。我会为你报告这件事。对造成的不便表示歉意。

于 2013-08-09T23:01:24.130 回答