Method: spaces.members.create
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
為通話 Chat 應用程式、使用者或 Google 群組建立成員資格。目前不支援為其他 Chat 應用程式建立成員資格。建立成員時,如果指定成員關閉了自動接受政策,系統會傳送邀請給對方,且對方必須接受邀請才能加入。否則,建立成員資格會直接將成員新增至指定聊天室。
支援下列類型的驗證:
應用程式驗證 (須經管理員核准),授權範圍如下:
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
(選用步驟) 時,這個方法會使用使用者的 Google Workspace 管理員權限執行。true 通話使用者必須是具備「管理即時通訊和聊天室對話」權限的 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
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-29 (世界標準時間)。
[null,null,["上次更新時間: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)."]]