【发布时间】:2016-05-19 20:07:11
【问题描述】:
我在 Google Apps 脚本中使用具有服务帐户授权的 Google Cloud Resource Manager API。在程序中,我有兴趣更新开发者控制台项目的角色。
具体来说,我正在尝试将开发者控制台项目的所有者更改为编辑器,并将另一个用户更改为所有者。这一点,我相信就 HTTP 请求负载而言,它看起来像:
// 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="
}
我观察到的几件事:
将当前 owner(用户电子邮件)更改为 editor 并添加 新所有者(用户电子邮件)时,API 调用正在返回
SOLO_MUST_INVITE_OWNERS错误。在这里,我将服务帐户模拟为项目的初始所有者,具有所有必要的域范围访问权限但是,当我在 Google API Explorer 中使用相同的有效负载执行相同的调用时,它工作正常!
Google Cloud 和 Identity Management 文档似乎令人困惑。它说在某一点
"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() 之外还有其他方法来设置策略吗?
【问题讨论】:
标签: google-api google-apps google-cloud-platform