Package google.chat.v1

索引

ChatService

使开发者能够在 Google Chat 平台上构建 Chat 应用和集成。

CompleteImportSpace

rpc CompleteImportSpace(CompleteImportSpaceRequest) returns (CompleteImportSpaceResponse)

完成指定空间的导入流程,并使其对用户可见。

需要进行用户身份验证和全网域授权,并具有以下授权范围

  • https://www.googleapis.com/auth/chat.import

如需了解详情,请参阅授权 Google Chat 应用导入数据

授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/chat.import

如需了解详情,请参阅授权指南

CreateCustomEmoji

rpc CreateCustomEmoji(CreateCustomEmojiRequest) returns (CustomEmoji)

创建自定义表情符号。

自定义表情符号仅适用于 Google Workspace 账号,并且管理员必须为组织启用自定义表情符号。如需了解详情,请参阅了解 Google Chat 中的自定义表情符号管理自定义表情符号权限

需要使用以下授权范围进行用户身份验证

  • https://www.googleapis.com/auth/chat.customemojis
授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/chat.customemojis

如需了解详情,请参阅授权指南

CreateMembership

rpc CreateMembership(CreateMembershipRequest) returns (Membership)

为通话 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(仅限“导入模式聊天室”)
    • 当管理员账号通过身份验证时,用户身份验证会授予管理员权限,use_admin_accesstrue,并使用以下授权范围:
      • https://www.googleapis.com/auth/chat.admin.memberships

应用身份验证不支持以下使用情形:

  • 邀请 Workspace 组织(聊天室所属组织)外部的用户。
  • 向聊天室添加 Google 群组。
  • 将 Chat 应用添加到聊天室。

如需查看使用示例,请参阅:

授权范围

需要以下 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

如需了解详情,请参阅授权指南

CreateMessage

rpc CreateMessage(CreateMessageRequest) returns (Message)

在 Google Chat 聊天室中创建消息。有关示例,请参阅发送消息

支持以下类型的身份验证

  • 使用授权范围的应用身份验证
    • https://www.googleapis.com/auth/chat.bot
  • 通过以下授权范围之一进行用户身份验证
    • https://www.googleapis.com/auth/chat.messages.create
    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)

Chat 会根据您在请求中使用的身份验证类型,以不同的方式归因消息发送者。

下图显示了使用应用身份验证时,Chat 如何为消息添加属性。Chat 会将 Chat 应用显示为消息发送者。消息的内容可以包含文本 (text)、卡片 (cardsV2) 和辅助微件 (accessoryWidgets)。

通过应用身份验证发送的邮件

下图显示了在使用用户身份验证时,Chat 如何为消息添加属性。Chat 会将用户显示为消息发送者,并通过显示 Chat 应用的名称将消息归因于该应用。消息内容只能包含文本 (text)。

通过用户身份验证发送的消息

邮件大小上限(包括邮件内容)为 32,000 字节。

对于 webhook 请求,响应不包含完整消息。除了请求中的信息之外,响应仅填充 namethread.name 字段。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.create

如需了解详情,请参阅授权指南

CreateReaction

rpc CreateReaction(CreateReactionRequest) returns (Reaction)

创建回应并将其添加到消息中。如需查看示例,请参阅为消息添加回应

需要使用以下某个授权范围进行用户身份验证

  • https://www.googleapis.com/auth/chat.messages.reactions.create
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages.reactions.create

如需了解详情,请参阅授权指南

CreateSpace

rpc CreateSpace(CreateSpaceRequest) returns (Space)

创建聊天室。可用于在 Import mode 中创建命名空间或群聊。如需查看示例,请参阅创建聊天室

支持以下类型的身份验证

  • 应用身份验证,需要管理员批准,并使用以下授权范围之一:

    • https://www.googleapis.com/auth/chat.app.spaces.create
    • https://www.googleapis.com/auth/chat.app.spaces
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.spaces.create
    • https://www.googleapis.com/auth/chat.spaces
    • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)

以应用身份进行身份验证时,必须在请求中设置 space.customer 字段。

以应用身份进行身份验证时,Chat 应用会添加为聊天室的成员。不过,与人工身份验证不同的是,Chat 应用不会添加为聊天室管理员。默认情况下,所有聊天室成员都可以将 Chat 应用从聊天室中移除。如需仅允许聊天室管理员从聊天室中移除应用,请将 space.permission_settings.manage_apps 设置为 managers_allowed

创建聊天室时的成员资格取决于聊天室是否在 Import mode 中创建:

  • 导入模式:不创建任何成员。
  • 所有其他模式:将调用用户添加为成员。具体如下:
    • 使用应用身份验证时的应用本身。
    • 使用用户身份验证时的人类用户。

如果您在创建聊天室时收到 ALREADY_EXISTS 错误消息,请尝试使用其他 displayName。Google Workspace 组织内的现有聊天室可能已使用此显示名称。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.app.spaces.create
  • https://www.googleapis.com/auth/chat.app.spaces
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.create

如需了解详情,请参阅授权指南

DeleteCustomEmoji

rpc DeleteCustomEmoji(DeleteCustomEmojiRequest) returns (Empty)

删除自定义表情符号。默认情况下,用户只能删除自己创建的自定义表情符号。管理员分配的表情符号管理者可以删除组织中的任何自定义表情符号。请参阅了解 Google Chat 中的自定义表情符号

自定义表情符号仅适用于 Google Workspace 账号,并且管理员必须为组织启用自定义表情符号。如需了解详情,请参阅了解 Google Chat 中的自定义表情符号管理自定义表情符号权限

需要使用以下授权范围进行用户身份验证

  • https://www.googleapis.com/auth/chat.customemojis
授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/chat.customemojis

如需了解详情,请参阅授权指南

DeleteMembership

rpc DeleteMembership(DeleteMembershipRequest) returns (Membership)

删除会员资格。如需查看示例,请参阅从聊天室中移除用户或 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(仅限“导入模式聊天室”)
    • 当管理员账号通过身份验证时,用户身份验证会授予管理员权限,use_admin_accesstrue,并使用以下授权范围:
      • https://www.googleapis.com/auth/chat.admin.memberships

应用身份验证不支持以下使用情形:

  • 从聊天室中移除 Google 群组。
  • 从聊天室中移除 Chat 应用。

如需删除聊天室管理员的成员身份,请求者必须是聊天室管理员。如果您使用的是应用身份验证,则 Chat 应用必须是聊天室创建者。

授权范围

需要以下 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

如需了解详情,请参阅授权指南

DeleteMessage

rpc DeleteMessage(DeleteMessageRequest) returns (Empty)

删除消息。如需查看示例,请参阅删除消息

支持以下类型的身份验证

  • 使用授权范围进行应用身份验证

    • https://www.googleapis.com/auth/chat.bot
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)

使用应用身份验证时,请求只能删除调用 Chat 应用创建的消息。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages

如需了解详情,请参阅授权指南

DeleteReaction

rpc DeleteReaction(DeleteReactionRequest) returns (Empty)

删除对消息的回应。如需查看示例,请参阅删除回应

需要使用以下某个授权范围进行用户身份验证

  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.reactions

如需了解详情,请参阅授权指南

DeleteSpace

rpc DeleteSpace(DeleteSpaceRequest) returns (Empty)

删除指定聊天室。始终执行级联删除,这意味着聊天室的子资源(例如聊天室中发布的消息和聊天室中的成员资格)也会被删除。有关示例,请参阅删除聊天室

支持以下类型的身份验证

  • 管理员批准应用身份验证和授权范围:

    • https://www.googleapis.com/auth/chat.app.delete(仅限应用创建的聊天室)
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.delete
    • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)
    • 当管理员账号通过身份验证时,用户身份验证会授予管理员权限,use_admin_accesstrue,并使用以下授权范围:
      • https://www.googleapis.com/auth/chat.admin.delete
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.app.delete
  • https://www.googleapis.com/auth/chat.admin.delete
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.delete

如需了解详情,请参阅授权指南

FindDirectMessage

rpc FindDirectMessage(FindDirectMessageRequest) returns (Space)

返回与指定用户的现有私信。如果未找到任何私信空间,则返回 404 NOT_FOUND 错误。如需查看示例,请参阅查找私信

通过应用身份验证,返回指定用户与调用方 Chat 应用之间的私信聊天室。

如果使用用户身份验证,则返回指定用户与经过身份验证的用户之间的私信空间。

支持以下类型的身份验证

  • 使用授权范围进行应用身份验证

    • https://www.googleapis.com/auth/chat.bot
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.bot

如需了解详情,请参阅授权指南

GetAttachment

rpc GetAttachment(GetAttachmentRequest) returns (Attachment)

获取邮件附件的元数据。附件数据使用 media API 提取。如需查看示例,请参阅获取有关邮件附件的元数据

需要通过以下授权范围进行应用身份验证

  • https://www.googleapis.com/auth/chat.bot
授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/chat.bot

如需了解详情,请参阅授权指南

GetCustomEmoji

rpc GetCustomEmoji(GetCustomEmojiRequest) returns (CustomEmoji)

返回有关自定义表情符号的详细信息。

自定义表情符号仅适用于 Google Workspace 账号,并且管理员必须为组织启用自定义表情符号。如需了解详情,请参阅了解 Google Chat 中的自定义表情符号管理自定义表情符号权限

需要使用以下某个授权范围进行用户身份验证

  • https://www.googleapis.com/auth/chat.customemojis.readonly
  • https://www.googleapis.com/auth/chat.customemojis
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.customemojis
  • https://www.googleapis.com/auth/chat.customemojis.readonly

如需了解详情,请参阅授权指南

GetMembership

rpc GetMembership(GetMembershipRequest) returns (Membership)

返回有关会员资格的详细信息。如需查看示例,请参阅获取有关用户或 Google Chat 应用会员资格的详细信息

支持以下类型的身份验证

  • 应用身份验证,并具有以下授权范围之一:

    • https://www.googleapis.com/auth/chat.bot
    • https://www.googleapis.com/auth/chat.app.memberships(需要管理员审批
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.memberships.readonly
    • https://www.googleapis.com/auth/chat.memberships
    • 用户身份验证在管理员账号通过身份验证时授予管理员权限,use_admin_accesstrue,并使用以下授权范围之一:
      • https://www.googleapis.com/auth/chat.admin.memberships.readonly
      • https://www.googleapis.com/auth/chat.admin.memberships
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.admin.memberships
  • https://www.googleapis.com/auth/chat.admin.memberships.readonly
  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.readonly

如需了解详情,请参阅授权指南

GetMessage

rpc GetMessage(GetMessageRequest) returns (Message)

返回有关消息的详细信息。如需查看示例,请参阅获取有关消息的详细信息

支持以下类型的身份验证

  • 应用身份验证,并具有以下授权范围之一:

    • https://www.googleapis.com/auth/chat.bot:使用此授权范围时,此方法会返回 Chat 应用有权访问的消息(例如私信和调用 Chat 应用的斜杠命令)的相关详细信息。
    • https://www.googleapis.com/auth/chat.app.messages.readonly 需要管理员批准(在开发者预览版中提供)。使用此身份验证范围时,此方法会返回有关聊天室中公开消息的详细信息。
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.messages.readonly
    • https://www.googleapis.com/auth/chat.messages

注意:可能会返回来自被屏蔽的成员或聊天室的消息。

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.readonly
  • https://www.googleapis.com/auth/chat.app.messages.readonly

如需了解详情,请参阅授权指南

GetSpace

rpc GetSpace(GetSpaceRequest) returns (Space)

返回有关聊天室的详细信息。如需查看示例,请参阅获取有关空间的详细信息

支持以下类型的身份验证

  • 应用身份验证,并具有以下授权范围之一:

    • https://www.googleapis.com/auth/chat.bot
    • https://www.googleapis.com/auth/chat.app.spaces 需要管理员批准
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
    • 用户身份验证在管理员账号通过身份验证时授予管理员权限,use_admin_accesstrue,并使用以下授权范围之一:
      • https://www.googleapis.com/auth/chat.admin.spaces.readonly
      • https://www.googleapis.com/auth/chat.admin.spaces

应用身份验证具有以下限制:

  • 只有在使用 chat.app.spaces 范围时,才会填充 space.access_settings
  • 只有在使用 chat.app.spaces 范围时,并且仅针对应用创建的聊天室,才会填充 space.predefind_permission_settingsspace.permission_settings
授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.admin.spaces
  • https://www.googleapis.com/auth/chat.admin.spaces.readonly
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.app.spaces

如需了解详情,请参阅授权指南

GetSpaceEvent

rpc GetSpaceEvent(GetSpaceEventRequest) returns (SpaceEvent)

返回 Google Chat 聊天室中的事件。事件载荷包含发生更改的资源的最新版本。例如,如果您请求有关新消息的事件,但该消息后来进行了更新,则服务器会在事件载荷中返回更新后的 Message 资源。

注意:对于此请求,空间事件数据的空间对象中不会返回 permissionSettings 字段。

支持以下类型的身份验证,并提供适合读取所请求数据的授权范围

  • 开发者预览版中,通过管理员批准进行应用身份验证,并使用以下授权范围之一:

    • https://www.googleapis.com/auth/chat.app.spaces
    • https://www.googleapis.com/auth/chat.app.messages.readonly
    • https://www.googleapis.com/auth/chat.app.memberships
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
    • https://www.googleapis.com/auth/chat.messages.readonly
    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.messages.reactions.readonly
    • https://www.googleapis.com/auth/chat.messages.reactions
    • https://www.googleapis.com/auth/chat.memberships.readonly
    • https://www.googleapis.com/auth/chat.memberships

如需获取活动,经过身份验证的调用者必须是相应聊天室的成员。

如需查看示例,请参阅获取 Google Chat 聊天室中活动的详细信息

授权范围

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.app.messages.readonly
  • https://www.googleapis.com/auth/chat.app.spaces
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.readonly
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.readonly
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages.reactions.readonly

如需了解详情,请参阅授权指南

GetSpaceNotificationSetting

rpc GetSpaceNotificationSetting(GetSpaceNotificationSettingRequest) returns (SpaceNotificationSetting)

获取聊天室通知设置。如需查看示例,请参阅获取调用者的空间通知设置

需要使用以下授权范围进行用户身份验证

  • https://www.googleapis.com/auth/chat.users.spacesettings
授权范围

需要以下 OAuth 范围:

  • https://www.googleapis.com/auth/chat.users.spacesettings

如需了解详情,请参阅授权指南

GetSpaceReadState

rpc GetSpaceReadState(GetSpaceReadStateRequest) returns (