【问题标题】:Google Drive API V3: Creating file permissions for a domainGoogle Drive API V3:为域创建文件权限
【发布时间】:2017-04-20 06:36:54
【问题描述】:

尝试通过 Google Drive 的 API V3 向文件添加权限时,我遇到了以下错误。我想允许来自我的站点 mta.io 的请求能够读取该文件。该错误似乎来自我在请求正文中传递的域,例如 example.com 工作正常并授予它权限。我是否需要将我的域列入白名单才能授予它对该文件的权限?

作品:

{
  "role": "reader",
  "type": "domain",
  "domain": "example.com"
}

不起作用:

{
  "role": "reader",
  "type": "domain",
  "domain": "mta.io"
}

错误:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "The specified domain is invalid or not applicable for the given permission type.",
    "locationType": "other",
    "location": "permission.domain"
   }
  ],
  "code": 400,
  "message": "The specified domain is invalid or not applicable for the given permission type."
 }
}

我正在使用 API 网站上的 try it 功能。

【问题讨论】:

    标签: javascript google-drive-api file-permissions


    【解决方案1】:

    想通了,您只能使用 G Suite 域。 这很糟糕,但要与域共享文件权限,您需要拥有 G Suite 帐户并验证您拥有该域 - 该域需要与您的 G Suite 帐户相关联。

    https://developers.google.com/drive/v3/web/about-permissions#types_and_values

    例如,具有域类型的权限可能具有域thecompany.com,表示该权限将给定角色授予G Suite域thecompany.com中的所有用户

    【讨论】:

      【解决方案2】:

      基于这个related thread,这只能在同一域中的用户之间进行,并且服务帐户不属于任何域。

      您最好的选择可能是创建服务帐户有权访问的团队云端硬盘,并执行一个两阶段流程:

      1. 使用服务帐户将文件移动到团队驱动器中。 Files.updateaddParents 参数设置为 Team Drive ID。
      2. 使用域用户将文件移出团队驱动器。 Files.updateaddParents 参数设置为 root(或某个目标文件夹的 ID),removeParents 参数设置为团队驱动器 ID。

      这是另一个可能也有帮助的 SO 帖子:Google Drive SDK - change item sharing permissions

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-08-18
        • 1970-01-01
        • 1970-01-01
        • 2017-10-22
        • 2020-10-23
        • 2016-12-09
        相关资源
        最近更新 更多