使用服务帐户和Google Admin SDK创建用户? [英] Create users using Service Account with Google Admin SDK?

查看:50
本文介绍了使用服务帐户和Google Admin SDK创建用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对此文档尚不清楚.我真的可以这样做吗?到目前为止,我仅看到来自Google文档的示例,该示例使用GoogleAuthorizationCodeFlow类显示了如何获得授权.我已经看到了一些使用服务帐户来更新和检索用户列表的示例,但是没有用于创建的示例.这可能吗?如果是这样,有人知道周围有什么例子吗?我似乎找不到能解决这个问题的任何东西.

The documentation is a little unclear on this. Can I actually do this? The only examples I've seen so far are from the Google documentation that show it using the GoogleAuthorizationCodeFlow class to gain authorization. I've seen a few examples of using the Service Account to update and retrieve a list of users, but nothing for creating. Is this possible? If so, does anyone know of any examples floating around? I can't seem to find anything that addresses it.

推荐答案

您可以按照以下API文档页面中概述的步骤创建服务帐户并执行域范围的授权,请记住您需要服务帐户可以代表其执行操作的域管理员的电子邮件地址:

You can follow the steps outlined in the following API docs page to create the service account and perform a domain wide delegation of authority, please bear in mind you need the email address of a domain administrator which the service account can act on their behalf:

https://developers.google.com/admin-sdk /directory/v1/guides/delegation

该页面包含一个Java示例,说明如何使用在Google Developers Console上创建的服务帐户和私钥实例化com.google.api.services.admin.directory.Directory对象.然后使用我在此答案中提供的示例创建用户:

The page includes a Java example of how to instantiate a com.google.api.services.admin.directory.Directory object using the service account and private key created on the Google Developers Console. Then use the example I've provided in this answer to create the users:

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆