Cho phép ứng dụng Google Chat nhập dữ liệu
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Với API Google Chat, các ứng dụng có thể nhập dữ liệu từ các nền tảng nhắn tin khác vào Google Chat bằng cách sử dụng không gian ở chế độ nhập. Để biết thêm thông tin, hãy xem bài viết Nhập dữ liệu tin nhắn vào Google Chat từ một dịch vụ khác.
Để đọc và ghi tài nguyên trong các không gian ở chế độ nhập, bạn phải xác thực các ứng dụng Chat bằng tài khoản dịch vụ.
Quản trị viên cấp cho tài khoản dịch vụ phạm vi uỷ quyền Chat API sau đây: https://www.googleapis.com/auth/chat.import
.
Chỉ quản trị viên miền Google Workspace mới có thể cấp phạm vi OAuth này cho tài khoản dịch vụ thông qua uỷ quyền trên toàn miền.
Mọi miền mà ứng dụng Chat tạo không gian ở chế độ nhập đều phải có phạm vi OAuth này. Sau khi tài khoản dịch vụ được uỷ quyền trên toàn miền cho phạm vi này, các ứng dụng Chat có thể truy cập vào không gian ở chế độ nhập bằng cách mạo danh tài khoản người dùng.
Trong một số trường hợp, tài khoản người dùng để mạo danh có thể không còn nữa. Trong những trường hợp này, ứng dụng Chat có thể sử dụng thông tin đăng nhập tài khoản dịch vụ của họ làm phương án dự phòng. Ví dụ: nếu bạn xoá một tài khoản người dùng đã được dùng trong quá trình tạo tin nhắn, thì ứng dụng Chat có thể dùng thông tin đăng nhập tài khoản dịch vụ của riêng mình để tạo một tin nhắn có cùng nội dung. Các ứng dụng Chat có thể truy cập vào các không gian ở chế độ nhập dưới dạng một ứng dụng sử dụng thông tin đăng nhập tài khoản dịch vụ với phạm vi OAuth sau: https://www.googleapis.com/auth/chat.bot
.
Bạn không cần phạm vi Google Chat API nào khác khi nhập tài nguyên vào không gian ở chế độ nhập.
Các ứng dụng Chat chỉ có thể nhập nội dung vào những không gian ở chế độ nhập mà chúng tạo, chứ không thể nhập nội dung vào những không gian ở chế độ nhập do các ứng dụng khác tạo.
Bảng sau đây liệt kê các phương thức tài nguyên mà ứng dụng Chat có thể gọi trong không gian ở chế độ nhập và loại xác thực mà các phương thức đó hỗ trợ:
Phương thức tài nguyên |
Hỗ trợ tính năng nhập vai người dùng |
Thông tin đăng nhập của tài khoản dịch vụ được hỗ trợ |
spaces.create
|
Có |
Không |
spaces.get
|
Không |
Có |
spaces.update
|
Có |
Không |
spaces.delete
|
Có |
Không |
spaces.completeImport
|
Có |
Không |
spaces.messages.create
|
Có |
Có |
spaces.messages.delete
|
Có |
Có |
spaces.messages.get
|
Không |
Có |
spaces.messages.list
|
Có |
Không |
spaces.messages.update
|
Có |
Có |
spaces.messages.reactions.create
|
Có |
Không |
spaces.messages.reactions.delete
|
Có |
Không |
spaces.members.create
|
Có |
Không |
spaces.members.delete
|
Có |
Không |
spaces.members.list
|
Có |
Không |
media.upload
|
Có |
Không |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[[["\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)."]]