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 (SpaceReadState)

返回有关聊天室中用户已读状态的详细信息,用于标识已读和未读消息。如需查看示例,请参阅获取有关用户空间读取状态的详细信息

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

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

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.users.readstate
  • https://www.googleapis.com/auth/chat.users.readstate.readonly

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

GetThreadReadState

rpc GetThreadReadState(GetThreadReadStateRequest) returns (ThreadReadState)

返回有关用户在线程中的已读状态的详细信息,用于标识已读和未读消息。如需查看示例,请参阅获取有关用户线程读取状态的详细信息

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

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

需要以下 OAuth 范围之一:

  • https://www.googleapis.com/auth/chat.users.readstate
  • https://www.googleapis.com/auth/chat.users.readstate.readonly

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

ListCustomEmojis

rpc ListCustomEmojis(ListCustomEmojisRequest) returns (ListCustomEmojisResponse)

列出已通过身份验证的用户可看到的自定义表情符号。

自定义表情符号仅适用于 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

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

ListMemberships

rpc ListMemberships(ListMembershipsRequest) returns (ListMembershipsResponse)

列出聊天室中的会员。如需查看示例,请参阅列出聊天室中的用户和 Google Chat 应用。使用应用身份验证列出成员时,系统会列出 Chat 应用有权访问的聊天室中的成员,但会排除 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
    • https://www.googleapis.com/auth/chat.import(仅限“导入模式聊天室”)
    • 用户身份验证在管理员账号通过身份验证时授予管理员权限,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.import
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.readonly

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

ListMessages

rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse)

列出调用者所属聊天室中的消息,包括来自被屏蔽的成员和聊天室的消息。系统消息(例如宣布有新聊天室成员加入的消息)不包括在内。如果您列出没有消息的聊天室中的消息,则响应为空对象。使用 REST/HTTP 接口时,响应包含一个空的 JSON 对象 {}。如需查看示例,请参阅列出消息

支持以下类型的身份验证

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

    • https://www.googleapis.com/auth/chat.app.messages.readonly。使用此身份验证范围时,此方法仅返回聊天室中的公开消息。不包括私信。
  • 使用以下授权范围之一进行用户身份验证

    • https://www.googleapis.com/auth/chat.messages.readonly
    • 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.readonly
  • https://www.googleapis.com/auth/chat.app.messages.readonly

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

ListReactions

rpc ListReactions(ListReactionsRequest) returns (ListReactionsResponse)

列出对消息的回应。如需查看示例,请参阅列出消息的表情符号回应

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

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

需要以下 OAuth 范围之一:

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

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

ListSpaceEvents

rpc ListSpaceEvents(ListSpaceEventsRequest) returns (ListSpaceEventsResponse)

列出 Google Chat 聊天室中的活动。对于每个事件,载荷都包含聊天资源的最最新版本。例如,如果您列出有关新聊天室成员的活动,服务器会返回包含最新成员资格详细信息的 Membership 资源。如果新会员在请求的时间段内被移除,则事件载荷包含一个空的 Membership 资源。

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

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

    • 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

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

ListSpaces

rpc ListSpaces(ListSpacesRequest) returns (ListSpacesResponse)

列出调用方所属的聊天室。在发送第一条消息之前,群聊和私信不会显示在列表中。如需查看示例,请参阅列出空间

支持以下类型的身份验证

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

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

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

如需按 Google Workspace 组织列出所有已命名的空间,请改用具有 Workspace 管理员权限的 spaces.search() 方法。

授权范围

需要以下 OAuth 范围之一:

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

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

SearchSpaces

rpc SearchSpaces(SearchSpacesRequest) returns (SearchSpacesResponse)

根据管理员的搜索返回 Google Workspace 组织中的聊天室列表。在请求中,将 use_admin_access 设置为 true。如需查看示例,请参阅搜索和管理聊天室

需要具有管理员权限的用户身份验证和以下授权范围之一:

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

需要以下 OAuth 范围之一:

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

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

SetUpSpace

rpc SetUpSpace(SetUpSpaceRequest) returns (Space)

创建聊天室并将指定用户添加到其中。调用用户会自动添加到聊天室,不应在请求中指定为成员。如需查看示例,请参阅设置包含初始成员的空间

如需指定要添加的人员成员,请添加具有相应 membership.member.name 的成员资格。如需添加人工用户,请使用 users/{user},其中 {user} 可以是用户的电子邮件地址。对于同一 Workspace 组织中的用户,{user} 也可以是 People API 中人员的 id,或 Directory API 中用户的 id。例如,如果 [email protected] 的 People API Person 个人资料 ID 为 123456789,您可以通过将 membership.member.name 设置为 users/[email protected]users/123456789 来将该用户添加到空间。

如需指定要添加的 Google 群组,请添加具有相应 membership.group_member.name 的会员资格。如需添加或邀请 Google 群组,请使用 groups/{group},其中 {group} 是 Cloud Identity Groups API 中群组的 id。例如,您可以使用 Cloud Identity Groups 查找 API 检索群组电子邮件地址 [email protected] 的 ID 123456789,然后将 membership.group_member.name 设置为 groups/123456789,从而将该群组添加到聊天室。不支持群组电子邮件,并且只能在命名聊天室中将 Google 群组添加为成员。

对于命名聊天室或群组对话,如果主叫方屏蔽了部分成员或被部分成员屏蔽,或者没有权限添加部分成员,则这些成员不会被添加到创建的聊天室中。

如需在调用用户与另一位人类用户之间创建私信 (DM),请指定一个成员身份来表示该人类用户。如果其中一位用户屏蔽了另一位用户,则请求会失败,并且不会创建私信。

如需在调用用户和调用应用之间创建私信,请将 Space.singleUserBotDm 设置为 true,并且不指定任何成员。您只能使用此方法设置与调用应用的直接消息。如需将调用应用添加为聊天室或两个人类用户之间现有直接消息的成员,请参阅邀请用户或应用加入聊天室或将用户或应用添加到聊天室

如果两位用户之间已存在私信,即使其中一位用户在发出请求时屏蔽了另一位用户,系统也会返回现有的私信。

不支持包含串联回复的群组。如果您在设置聊天室时收到 ALREADY_EXISTS 错误消息,请尝试使用其他 displayName。Google Workspace 组织内的现有聊天室可能已使用此显示名称。

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

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

需要以下 OAuth 范围之一:

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

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

UpdateMembership

rpc UpdateMembership(UpdateMembershipRequest) returns (Membership)

更新会员资格。如需查看示例,请参阅更新用户在聊天室中的成员身份

支持以下类型的身份验证

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

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

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

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

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

UpdateMessage

rpc UpdateMessage(UpdateMessageRequest) returns (Message)

更新消息。patch 方法和 update 方法之间存在差异。patch 方法使用 patch 请求,而 update 方法使用 put 请求。我们建议使用 patch 方法。如需查看示例,请参阅更新消息

支持以下类型的身份验证

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

    • 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

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

UpdateSpace

rpc UpdateSpace(UpdateSpaceRequest) returns (Space)

更新空间。如需查看示例,请参阅更新会议室

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

支持以下类型的身份验证

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

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

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

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

  • 如需更新 space.predefined_permission_settingsspace.permission_settings,应用必须是聊天室创建者。
  • 不支持为应用身份验证更新 space.access_settings.audience
授权范围

需要以下 OAuth 范围之一:

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

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

UpdateSpaceNotificationSetting

rpc UpdateSpaceNotificationSetting(UpdateSpaceNotificationSettingRequest) returns (SpaceNotificationSetting)

更新聊天室通知设置。如需查看示例,请参阅更新调用者的会议室通知设置

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

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

需要以下 OAuth 范围:

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

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

UpdateSpaceReadState

rpc UpdateSpaceReadState(