授权 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
|
是 |
否 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-21。
[null,null,["最后更新时间 (UTC):2024-12-21。"],[[["Google Chat API allows importing data from other platforms into Google Chat using import mode spaces."],["Chat apps require specific authentication and authorization to read and write resources in these spaces, needing domain administrator approval."],["Apps can impersonate user accounts or utilize their service account credentials for specific actions within import mode spaces."],["Import mode spaces support various resource methods with differing authentication requirements, as detailed in the provided table."],["Chat apps can only import content into spaces they create and not into spaces created by other apps."]]],["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"]]