问题描述
考虑这种情况:
我有两个域:Animated
和domain1.net
。
我在domain2.net
上启用了GCP,并在此处创建了启用了域范围委派的服务帐户。
此服务帐户中的domain1.net
在CLIENT ID
GSuite管理控制台上配置为域范围的委派,并启用了以下domain1.net
作用域:
OAuth2
我有一个ScopES = [
'https://www.googleapis.com/auth/admin.directory.group','https://www.googleapis.com/auth/admin.directory.group.readonly','https://www.googleapis.com/auth/admin.directory.group.member','https://www.googleapis.com/auth/admin.directory.group.member.readonly',]
,该人使用服务帐户的权限来创建Cloud Function
,以便能够访问GSuite OAuth2 JWT
API。 Code Sample Here.
要模拟GSuite的用户具有组管理员角色,可以创建GSuite组。
所有这些配置均能完美运行,我能够使用domain1.net
GCP env中的Cloud Funtion在domain1.net
中创建组。
但是,如果我在domain1.net
中使用相同的服务帐户CLIENT ID
并赋予相同的domain2.net
范围,请创建一个具有“组管理员”角色的用户,并使用该用户创建新的组,不行。
错误:
OAuth2
现在,上面的错误代码:在this documentation中找到的error got with oauth2client==4.1.3
oauth2client.client.HttpAccesstokenRefreshError: unauthorized_client: Client is unauthorized to retrieve access tokens using this method,or client not authorized for any of the scopes requested.
error got with google.oauth2:
googleapiclient.errors.HttpError: unauthorized_client: Client is unauthorized to retrieve access tokens using this method,or client not authorized for any of the scopes requested.
指定unauthorized_client
不正确,我可能已经使用了服务帐户的电子邮件,而我没有使用。
跨域委派可以跨GSuite组织(不同域)吗?
我知道它可以在CLIENT ID
的任何子域中使用,但不能在任何其他GSuite组织(domain1.net
等不同的域)中使用。
解决方法
我对您有个好消息(这不会回答您的问题,但会解决您的问题)!
您不再需要模拟管理员来创建群组。 Google刚刚在上周宣布,Cloud Identity Groups API现在将允许通过API进行组管理,而无需冒充管理员。
看看这些更新博客:
https://gsuiteupdates.googleblog.com/2020/08/service-accounts-in-google-groups-beta.html
https://gsuiteupdates.googleblog.com/2020/08/new-api-cloud-identity-groups-google.html
我无法帮助您解决实际问题,那不是我的领土。
,服务帐户属于您为其创建的应用程序。如果此应用程序属于domain1.net
,则该服务帐户将能够模拟来自domain1.net
的帐户,而不是来自其他任何域的帐户。
如果您希望服务帐户模拟来自domain2.net
的用户,请在属于domain2.net
的GCP项目上创建另一个服务帐户。