Method: spaces.members.create
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为通话 Chat 应用、用户或 Google 群组创建会员资格。不支持为其他聊天应用创建会员资格。创建会员时,如果指定会员关闭了自动接受政策,则系统会向其发送邀请,并且该会员必须接受聊天室邀请才能加入。否则,创建会员资格会将相应成员直接添加到指定空间。
支持以下类型的身份验证:
应用身份验证(需经管理员批准)和授权范围:
https://www.googleapis.com/auth/chat.app.memberships
使用以下授权范围之一进行用户身份验证:
https://www.googleapis.com/auth/chat.memberships
https://www.googleapis.com/auth/chat.memberships.app
(将发起调用的应用添加到聊天室)
https://www.googleapis.com/auth/chat.import
(仅限“导入模式聊天室”)
- 当管理员账号通过身份验证时,用户身份验证会授予管理员权限,
useAdminAccess
为 true
,并使用以下授权范围:
https://www.googleapis.com/auth/chat.admin.memberships
应用身份验证不支持以下使用情形:
- 邀请 Workspace 组织(聊天室所属组织)外部的用户。
- 向聊天室添加 Google 群组。
- 将 Chat 应用添加到聊天室。
如需查看使用示例,请参阅:
HTTP 请求
POST https://chat.googleapis.com/v1/{parent=spaces/*}/members
网址采用 gRPC 转码语法。
路径参数
参数 |
parent |
string
必需。要为其创建会员资格的空间的资源名称。 格式:spaces/{space}
|
查询参数
参数 |
useAdminAccess |
boolean
可选。如果值为 true ,则该方法会使用用户的 Google Workspace 管理员权限运行。 调用用户必须是拥有“管理聊天和聊天室对话”权限的 Google Workspace 管理员。 需要 chat.admin.memberships OAuth 2.0 范围。 使用管理员访问权限不支持创建应用会员资格或为管理员的 Google Workspace 组织之外的用户创建会员资格。
|
请求正文
请求正文包含一个 Membership
实例。
响应正文
如果成功,响应正文将包含一个新创建的 Membership
实例。
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/chat.app.memberships
https://www.googleapis.com/auth/chat.admin.memberships
https://www.googleapis.com/auth/chat.import
https://www.googleapis.com/auth/chat.memberships
https://www.googleapis.com/auth/chat.memberships.app
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-29。
[null,null,["最后更新时间 (UTC):2025-07-29。"],[[["\u003cp\u003eCreates memberships for the calling Chat app, a user, or a Google Group in a specified space.\u003c/p\u003e\n"],["\u003cp\u003eSupports app authentication (with admin approval in Developer Preview) and user authentication (with optional admin access).\u003c/p\u003e\n"],["\u003cp\u003eTo use administrator privileges, set the \u003ccode\u003euseAdminAccess\u003c/code\u003e query parameter to \u003ccode\u003etrue\u003c/code\u003e and ensure the user has the required permissions and scope.\u003c/p\u003e\n"],["\u003cp\u003eRequires specific OAuth scopes for authorization, such as \u003ccode\u003echat.app.memberships\u003c/code\u003e or \u003ccode\u003echat.admin.memberships\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIf the member has auto-accept turned off, an invitation is sent; otherwise, they are directly added to the space.\u003c/p\u003e\n"]]],["This describes how to create a membership in Google Chat spaces using a `POST` request to `https://chat.googleapis.com/v1/{parent=spaces/*}/members`. Memberships can be created for a Chat app, user, or Google Group. Authentication supports app or user access, with optional administrator privileges via the `useAdminAccess` query parameter. The request includes path and query parameters and a `Membership` object in the body; the response returns the newly created `Membership`. Authorization requires specific OAuth scopes.\n"],null,["# Method: spaces.members.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nCreates a membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space.\n\nSupports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):\n\n- [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with [administrator approval](https://support.google.com/a?p=chat-app-auth) and the authorization scope:\n\n - `https://www.googleapis.com/auth/chat.app.memberships`\n- [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following authorization scopes:\n\n - `https://www.googleapis.com/auth/chat.memberships`\n - `https://www.googleapis.com/auth/chat.memberships.app` (to add the calling app to the space)\n - `https://www.googleapis.com/auth/chat.import` (import mode spaces only)\n - User authentication grants administrator privileges when an administrator account authenticates, `useAdminAccess` is `true`, and the following authorization scope is used:\n - `https://www.googleapis.com/auth/chat.admin.memberships`\n\nApp authentication is not supported for the following use cases:\n\n- Inviting users external to the Workspace organization that owns the space.\n- Adding a Google Group to a space.\n- Adding a Chat app to a space.\n\nFor example usage, see:\n\n- [Invite or add a user to a space](https://developers.google.com/workspace/chat/create-members#create-user-membership).\n- [Invite or add a Google Group to a space](https://developers.google.com/workspace/chat/create-members#create-group-membership).\n- [Add the Chat app to a space](https://developers.google.com/workspace/chat/create-members#create-membership-calling-api).\n\n### HTTP request\n\n`POST https://chat.googleapis.com/v1/{parent=spaces/*}/members`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|--------------------------------------------------------------------------------------------------------------|\n| `parent` | `string` Required. The resource name of the space for which to create the membership. Format: spaces/{space} |\n\n### Query parameters\n\n| Parameters ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `useAdminAccess` | `boolean` Optional. When `true`, the method runs using the user's Google Workspace administrator privileges. The calling user must be a Google Workspace administrator with the [manage chat and spaces conversations privilege](https://support.google.com/a/answer/13369245). Requires the `chat.admin.memberships` [OAuth 2.0 scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes). Creating app memberships or creating memberships for users outside the administrator's Google Workspace organization isn't supported using admin access. |\n\n### Request body\n\nThe request body contains an instance of [Membership](/workspace/chat/api/reference/rest/v1/spaces.members#Membership).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Membership](/workspace/chat/api/reference/rest/v1/spaces.members#Membership).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/chat.app.memberships`\n- `https://www.googleapis.com/auth/chat.admin.memberships`\n- `https://www.googleapis.com/auth/chat.import`\n- `https://www.googleapis.com/auth/chat.memberships`\n- `https://www.googleapis.com/auth/chat.memberships.app`\n\nFor more information, see the [Authorization guide](/workspace/chat/authenticate-authorize)."]]