Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 跨GSuite组织域范围的委派_Google Cloud Platform_Oauth 2.0_Google Workspace_Google Directory Api - Fatal编程技术网

Google cloud platform 跨GSuite组织域范围的委派

Google cloud platform 跨GSuite组织域范围的委派,google-cloud-platform,oauth-2.0,google-workspace,google-directory-api,Google Cloud Platform,Oauth 2.0,Google Workspace,Google Directory Api,考虑以下情况: 我有两个域:domain1.net和domain2.net 我在domain1.net上启用了GCP,并在这里创建了一个服务帐户,该帐户启用了域范围的委派 此服务帐户的客户端ID在domain1.netGSuite管理控制台上配置为域范围的委派,并启用了以下OAuth2作用域: SCOPES = [ 'https://www.googleapis.com/auth/admin.directory.group', 'https://www.googleapis.co

考虑以下情况:

我有两个域:
domain1.net
domain2.net

我在
domain1.net
上启用了GCP,并在这里创建了一个服务帐户,该帐户启用了域范围的委派

此服务帐户的
客户端ID
domain1.net
GSuite管理控制台上配置为域范围的委派,并启用了以下
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',
]
我有一个
云功能
,它使用服务帐户的权限创建
OAuth2 JWT
,以便能够访问GSuite
domain1.net
API

要在GSuite中模拟的用户具有组管理员角色,可以创建GSuite组

所有这些配置都非常有效,我能够在
domain1.net
中使用
domain1.net
GCP env中的云功能在
domain1.net
中创建组

但是,如果我在
domain2.net
中使用相同的服务帐户
CLIENT ID
,给相同的
OAuth2
作用域,创建一个具有组管理员角色的用户,并使用此用户创建新组,则它不起作用

错误:

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\u client
在中找到指定
客户端ID
不正确,我可能使用了服务帐户的电子邮件,但我没有使用

跨GSuite组织(不同域)的域范围授权是否可行? 我知道它适用于
domain1.net
的任何子域,但不适用于任何其他GSuite组织(不同的域,如
domain2.net
)。

我有好消息告诉你(这不会回答你的问题,但会解决你的问题)

您不再需要模拟管理员来创建组。谷歌上周刚刚宣布,云身份组API现在将允许通过API进行组管理,而不模拟管理员

看看这些更新博客:


我不能帮你解决实际问题,tho;那不是我的地盘。

服务帐户属于您为其创建的应用程序。如果此应用程序属于
domain1.net
,则服务帐户将能够模拟来自
domain1.net
,而不是来自任何其他域的帐户

如果希望服务帐户模拟来自
domain2.net
的用户,请在属于
domain2.net
的GCP项目上创建另一个服务帐户

参考: