从 Google 域中获取所有用户。 Google Admin SDK - 用户列表

Get all users from Google domain. Google Admin SDK - Users List

我想调用这个 api https://www.googleapis.com/admin/directory/v1/users.

我有一个来自 Google 控制台的应用程序,配置了信用凭证。 API 关键。

我是 google gsuite 域的管理员。

我打电话

https://www.googleapis.com/admin/directory/v1/users?domain=xxx-xxx.com&key=xxxxxxxxxxxxxxxxxx

我收到了这条消息

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "required",
                "message": "Login Required",
                "locationType": "header",
                "location": "Authorization"
            }
        ],
        "code": 401,
        "message": "Login Required"
    }
}

我不明白它应该如何工作。

从G suite获取所有用户非常简单。您有用于在 this 网页中列出来自 Gsuite 的用户的代码。在左侧面板上选择您现在使用的语言。正确遵循指南。无需更改一行代码。我按照 java 快速入门列出了 G 套件中的所有用户。

你也可以试试这个-

  • 您可以使用 Google API Explorer
  • 转到this网页
  • 您可以找到 "Try this API" iframe 或只需按右侧面板上的 "Try it" 按钮
  • 参考页面并提供所需参数。
  • 只需提供您的域和 orderBy 作为参数。
  • 它将打开一个新的window并要求进行身份验证和授权
  • 授权完成后,您Gsuite中的用户将以JSON格式显示。