Method: groups.list
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
指定 userKey 后,检索网域或用户的所有群组(分页)。
HTTP 请求
GET https://admin.googleapis.com/admin/directory/v1/groups
网址采用 gRPC 转码语法。
查询参数
参数 |
customer |
string
客户 Google Workspace 账号的唯一 ID。如果是多网域账号,如需提取客户的所有群组,请使用此字段,而不是 domain 。您还可以使用 my_customer 别名来表示账号的 customerId 。customerId 也会作为 Users 资源的一部分返回。您必须提供 customer 或 domain 参数。
|
domain |
string
域名。使用此字段可仅获取一个网域中的群组。如需返回客户账号的所有网域,请改用 customer 查询参数。
|
maxResults |
integer
返回的结果数上限。允许的最大值为 200。
|
orderBy |
enum (OrderBy )
用于对结果进行排序的列
|
pageToken |
string
用于指定列表中下一页的令牌
|
query |
string
查询字符串搜索。应采用“”格式。如需查看完整文档,请访问 https: //developers.google.com/workspace/admin/directory/v1/guides/search-groups
|
sortOrder |
enum (SortOrder )
是按升序还是降序返回结果。仅在同时使用 orderBy 时才有用
|
userKey |
string
用户的电子邮件地址或不可变 ID(如果仅要列出指定用户所属的群组)。如果是 ID,则应与用户对象的 ID 一致。不能与 customer 参数搭配使用。
|
响应正文
JSON 表示法 |
{
"kind": string,
"etag": string,
"groups": [
{
object (Group )
}
],
"nextPageToken": string
} |
字段 |
kind |
string
资源的类型。
|
etag |
string
资源的 ETag。
|
groups[] |
object (Group )
组对象的列表。
|
nextPageToken |
string
用于访问此结果的下一页的令牌。
|
授权范围
需要以下 OAuth 范围之一:
https://apps-apis.google.com/a/feeds/groups/
https://www.googleapis.com/auth/admin.directory.group
https://www.googleapis.com/auth/admin.directory.group.readonly
如需了解详情,请参阅授权指南。
SortOrder
枚举 |
ASCENDING |
升序。 |
DESCENDING |
降序。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Method: groups.list\n\nRetrieves all groups of a domain or of a user given a userKey (paginated).\n\n### HTTP request\n\n`GET https://admin.googleapis.com/admin/directory/v1/groups`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Query parameters\n\n| Parameters ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `customer` | `string` The unique ID for the customer's Google Workspace account. In case of a multi-domain account, to fetch all groups for a customer, use this field instead of `domain`. You can also use the `my_customer` alias to represent your account's `customerId`. The `customerId` is also returned as part of the [Users](https://developers.google.com/workspace/admin/directory/v1/reference/users) resource. You must provide either the `customer` or the `domain` parameter. |\n| `domain` | `string` The domain name. Use this field to get groups from only one domain. To return all domains for a customer account, use the `customer` query parameter instead. |\n| `maxResults` | `integer` Maximum number of results to return. Max allowed value is 200. |\n| `orderBy` | `enum (`[OrderBy](/workspace/admin/directory/reference/rest/v1/groups/list#OrderBy)`)` Column to use for sorting results |\n| `pageToken` | `string` Token to specify next page in the list |\n| `query` | `string` Query string search. Should be of the form \"\". Complete documentation is at https: //developers.google.com/workspace/admin/directory/v1/guides/search-groups |\n| `sortOrder` | `enum (`[SortOrder](/workspace/admin/directory/reference/rest/v1/groups/list#SortOrder)`)` Whether to return results in ascending or descending order. Only of use when orderBy is also used |\n| `userKey` | `string` Email or immutable ID of the user if only those groups are to be listed, the given user is a member of. If it's an ID, it should match with the ID of the user object. Cannot be used with the `customer` parameter. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"kind\": string, \"etag\": string, \"groups\": [ { object (/workspace/admin/directory/reference/rest/v1/groups#Group) } ], \"nextPageToken\": string } ``` |\n\n| Fields ||\n|-----------------|----------------------------------------------------------------------------------------------------------|\n| `kind` | `string` Kind of resource this is. |\n| `etag` | `string` ETag of the resource. |\n| `groups[]` | `object (`[Group](/workspace/admin/directory/reference/rest/v1/groups#Group)`)` A list of group objects. |\n| `nextPageToken` | `string` Token used to access next page of this result. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://apps-apis.google.com/a/feeds/groups/`\n- `\n https://www.googleapis.com/auth/admin.directory.group`\n- `\n https://www.googleapis.com/auth/admin.directory.group.readonly`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent).\n\nOrderBy\n-------\n\n| Enums ||\n|---------|---------------------|\n| `EMAIL` | Email of the group. |\n\nSortOrder\n---------\n\n| Enums ||\n|--------------|-------------------|\n| `ASCENDING` | Ascending order. |\n| `DESCENDING` | Descending order. |"]]