用于 python 插入的 G 套件管理 SDK

G suite admin SDK for python insert

我正在尝试查找有关 G Suite 如何处理 python 中的 api 调用的代码示例。例如,有一个名为 insert: https://developers.google.com/admin-sdk/directory/v1/reference/users/insert#try-it 的方法允许您在您的企业下创建新用户。

关键是他们没有关于如何做到这一点的示例,我发现通过他们的文档很难弄明白。有没有我可以参考的已知示例?

这对我有用,还使用了快速入门指南。

首先,使用最少的必填字段构建您的用户对象。

请注意,这只是一个包含用户对象基本表示的字典。

要使用的最少字段如下所示:

user = {"name": {"familyName": "Burton", "givenName": "Haniel",}, "password": "some_pass", "primaryEmail": "haniel@yourgsuitedomain.com",}

您可以像任何其他词典一样添加或更新其他字段:

 user["orgUnitPath"] = "/Imported"

然后,在您的 main() 程序中像这样调用插入方法:

    result = service.users().insert(body=user).execute()

结果应该是目录 API 返回的 JSON 表示形式,具有由 Google 自动添加的附加属性。

一些额外的链接,以防其他人觉得有用: https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/python/latest/admin_directory_v1.users.html

我正在构建一个小型 script/app 来处理用户创建、更新和密码重置,以自动从我们的学生信息系统进行配置。根据进展情况,我可能会 post 到 GitHub 并在此处添加链接以节省其他人的时间。