Google Cloud Resource Manager API - 向用户授予所有者角色

时间:2016-02-09 17:53:45

标签: google-api google-apps google-cloud-platform

我在Google Apps脚本中使用Google Cloud Resource Manager API服务帐户授权。在程序中,我有兴趣更新Developer Console Project的角色。

具体来说,我正在尝试将Developer Console项目的所有者更改为编辑器,将另一个用户更改为所有者。我相信在HTTP Request有效载荷方面看起来像:

// before (taken from response of getIamPolicy REST call)
{
    "bindings": [{
            "role": "roles/owner",
            "members": ["user:abc@my-google-domain.com"]
     }],
    "version": "0",
    "etag": "acbqwcada="
}

// after (modified policy) used in setIamPolicy REST call
{
    "bindings": [{
            "role": "roles/owner",
            "members": ["user:def@my-google-domain.com"]
     },
     {
            "role": "roles/editor",
            "members": ["user:abc@my-google-domain.com"]
     }],
    "version": "0",
    "etag": "acbqwcada="
}

我观察到的一些事情:

  • 将当前所有者(用户电子邮件)更改为编辑器并添加新所有者(用户电子邮件)时,API调用将返回SOLO_MUST_INVITE_OWNERS错误。在这里,我冒充服务帐户作为项目的初始所有者,具有所有必要的域范围访问权限

  • 但是,当我在Google API资源管理器中使用相同的有效负载执行相同的调用时,其工作正常!

  • Google Cloud和身份管理文档似乎令人困惑。它在一点"Cloud Resource Manager IAM methods only support granting the owner role to user and serviceAccount"而在另一点"A user cannot be granted owner access using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and he must explicitly accept the invitation."中说 - 我想知道除了setIamPolicy()之外还有其他任何方法来设置策略吗?

1 个答案:

答案 0 :(得分:1)

Cloud Resource Manager API不支持通过setIamPolicysee the documentation on setIamPolicy添加所有者:

  

要添加为所有者,必须通过Cloud Platform邀请用户   控制台,必须接受邀请。

在您邀请def@my-google-domain.com并且他们已经接受之后(他们将在Cloud Platform控制台中作为项目的所有者出现,并且也是{{{}的成员由owner返回的1}}绑定您可以进行getIamPolicy调用,使setIamPolicy成为abc@my-google-domain.com

相关问题