授權 Google Chat 應用程式匯入資料
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
應用程式可透過 Google Chat API,使用匯入模式聊天室將資料從其他訊息平台匯入 Google Chat。詳情請參閱「將訊息資料從其他服務匯入 Google Chat」。
如要在匯入模式的空間中讀取及寫入資源,您必須使用服務帳戶驗證 Chat 應用程式。由管理員將下列 Chat API 授權範圍授予服務帳戶:https://www.googleapis.com/auth/chat.import
。
只有 Google Workspace 網域管理員可以透過全網域委派,將這個 OAuth 範圍授予服務帳戶。如果網域中的 Chat 擴充應用程式會建立匯入模式聊天室,就必須具備這個 OAuth 範圍。服務帳戶獲得這個範圍的全網域授權後,Chat 應用程式就能模擬使用者帳戶,存取匯入模式的聊天室。
在某些情況下,用於模擬的使用者帳戶可能已無法使用。在這種情況下,Chat 應用程式可以改用服務帳戶憑證。舉例來說,如果您刪除用於建立訊息的使用者帳戶,Chat 應用程式可以使用自己的服務帳戶憑證,建立含有相同內容的訊息。Chat 應用程式可使用服務帳戶憑證,透過下列 OAuth 範圍以應用程式身分存取匯入模式的空間:https://www.googleapis.com/auth/chat.bot
。
將資源匯入匯入模式空間時,不需要其他 Google Chat API 範圍。Chat 應用程式只能將內容匯入自行建立的匯入模式聊天室,無法匯入其他應用程式建立的匯入模式聊天室。
下表列出 Chat 應用程式可在匯入模式空間中呼叫的資源方法,以及支援的驗證類型:
資源方法 |
支援使用者模擬 |
支援的服務帳戶憑證 |
spaces.create
|
是 |
否 |
spaces.get
|
否 |
是 |
spaces.update
|
是 |
否 |
spaces.delete
|
是 |
否 |
spaces.completeImport
|
是 |
否 |
spaces.messages.create
|
是 |
是 |
spaces.messages.delete
|
是 |
是 |
spaces.messages.get
|
否 |
是 |
spaces.messages.list
|
是 |
否 |
spaces.messages.update
|
是 |
是 |
spaces.messages.reactions.create
|
是 |
否 |
spaces.messages.reactions.delete
|
是 |
否 |
spaces.members.create
|
是 |
否 |
spaces.members.delete
|
是 |
否 |
spaces.members.list
|
是 |
否 |
media.upload
|
是 |
否 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[[["\u003cp\u003eGoogle Chat API allows importing data from other platforms into Google Chat using import mode spaces.\u003c/p\u003e\n"],["\u003cp\u003eChat apps require specific authentication and authorization to read and write resources in these spaces, needing domain administrator approval.\u003c/p\u003e\n"],["\u003cp\u003eApps can impersonate user accounts or utilize their service account credentials for specific actions within import mode spaces.\u003c/p\u003e\n"],["\u003cp\u003eImport mode spaces support various resource methods with differing authentication requirements, as detailed in the provided table.\u003c/p\u003e\n"],["\u003cp\u003eChat apps can only import content into spaces they create and not into spaces created by other apps.\u003c/p\u003e\n"]]],["Apps use the Google Chat API's import mode to bring data from other platforms into Google Chat. This requires authentication with a service account granted the `https://www.googleapis.com/auth/chat.import` scope via domain-wide delegation by a Google Workspace admin. Apps can impersonate user accounts or use service account credentials (`https://www.googleapis.com/auth/chat.bot`). Only specific resource methods are supported in import mode spaces. Import mode is exclusive, meaning apps can only modify spaces they create.\n"],null,["# Authorize Google Chat apps to import data\n\nWith the Google Chat API, apps can import data from other messaging platforms into\nGoogle Chat by using *import mode* spaces. For more information, see\n[Import message data to Google Chat from another service](https://support.google.com/a/answer/13465849).\n\nTo read and write resources in import mode spaces, you must\n[authenticate Chat apps with a service account](/workspace/chat/authenticate-authorize-chat-app).\nGrant the service account the following Chat API authorization scope\nby an administrator: `https://www.googleapis.com/auth/chat.import`.\n\nOnly Google Workspace domain administrators can grant this OAuth scope to\nservice accounts through\n[domain-wide delegation](/identity/protocols/oauth2/service-account#delegatingauthority).\nEvery domain that a Chat app creates import mode spaces\nin must have this OAuth scope. After the service account has been delegated\ndomain-wide authority for this scope, Chat apps can access import\nmode spaces by\n[impersonating a user account](/identity/protocols/oauth2/service-account#authorizingrequests).\n\nIn some scenarios, the user account for impersonation might no longer be\navailable. In these cases, the Chat app can use their\nservice account credentials as a fallback. For example, if you delete a user\naccount that was used during message creation, the\nChat app can use their own service account credentials\nto create a message containing the same contents. Chat apps can\naccess import mode spaces as an app using service account credentials with the\nfollowing OAuth scope: `https://www.googleapis.com/auth/chat.bot`.\n\nNo other [Google Chat API scopes](/workspace/chat/authenticate-authorize#scopes)\nare required when importing resources into an import mode space.\nChat apps can only import content into the import mode spaces\nthat they create, and not into the import mode spaces created by other apps.\n\nThe following table lists the resource methods that Chat apps can\ncall in import mode spaces, and what kind of authentication they support:\n\n| Resource method | User impersonation supported | Service account credentials supported |\n|------------------------------------|------------------------------|---------------------------------------|\n| `spaces.create` | Yes | No |\n| `spaces.get` | No | Yes |\n| `spaces.update` | Yes | No |\n| `spaces.delete` | Yes | No |\n| `spaces.completeImport` | Yes | No |\n| `spaces.messages.create` | Yes | Yes |\n| `spaces.messages.delete` | Yes | Yes |\n| `spaces.messages.get` | No | Yes |\n| `spaces.messages.list` | Yes | No |\n| `spaces.messages.update` | Yes | Yes |\n| `spaces.messages.reactions.create` | Yes | No |\n| `spaces.messages.reactions.delete` | Yes | No |\n| `spaces.members.create` | Yes | No |\n| `spaces.members.delete` | Yes | No |\n| `spaces.members.list` | Yes | No |\n| `media.upload` | Yes | No |\n\nRelated topics\n--------------\n\n- To learn more about authentication and authorization, see [Authenticate and authorize Google Chat apps and API requests](/workspace/chat/authenticate-authorize).\n- To learn how to set up a service account to access the Google Chat API, see [Authenticate as a Google Chat app](/workspace/chat/authenticate-authorize-chat-app).\n- To learn how to start importing resources using import mode spaces, see [Import data to Google Chat](/workspace/chat/import-data)."]]