选择 Google Workspace Events API 范围

本文档包含 Google Workspace Events API 专属授权和身份验证信息。在阅读本文档之前,请务必阅读了解身份验证和授权中的 Google Workspace 常规身份验证和授权信息。

配置 OAuth 2.0 以进行授权

配置 OAuth 同意屏幕并选择范围,以定义向用户显示的信息和应用审核者,并注册您的应用,以便日后发布。

Google Workspace Events API 范围

如需定义授予应用的访问权限级别,您需要确定并声明授权范围。授权范围是一个 OAuth 2.0 URI 字符串,其中包含 Google Workspace 应用名称、所访问的数据类型和访问权限级别。范围是您的应用对 Google Workspace 数据(包括用户的 Google 账号数据)的处理请求。

安装应用时,系统会要求用户验证应用使用的范围。通常,您应尽可能选择范围最窄的范围,并避免请求应用不需要的范围。用户更容易授予对明确说明的有限范围的访问权限。

我们建议尽可能使用非敏感范围,因为它会授予每个文件的访问权限范围,并缩小对应用所需特定功能的访问权限。

Google Workspace Events API 使用支持订阅的 Google Workspace 应用中的范围。如果您的应用已经使用订阅所需的范围,那么您无需添加其他范围即可使用 Google Workspace Events API。

下表显示了 Google Workspace Events API 支持的范围:

范围代码 说明 用法
Google Chat  
https://www.googleapis.com/auth/chat.bot 允许 Google Chat 应用查看聊天对话和发送消息。授权使用 Chat 应用提供的所有功能。 非敏感
https://www.googleapis.com/auth/chat.memberships 查看、添加和移除 Google Chat 对话中的成员。
敏感内容
https://www.googleapis.com/auth/chat.memberships.readonly 查看 Google Chat 对话中的成员。
敏感内容
https://www.googleapis.com/auth/chat.spaces 在 Google Chat 中创建对话和聊天室,以及查看或更新元数据(包括聊天记录设置)。 敏感内容
https://www.googleapis.com/auth/chat.spaces.readonly 在 Google Chat 中查看聊天和聊天室。
敏感内容
https://www.googleapis.com/auth/chat.messages 查看、撰写、发送、更新和删除消息,以及添加、查看和删除对消息的回应。 受限
https://www.googleapis.com/auth/chat.messages.readonly 在 Google Chat 中查看消息和回应。
受限
https://www.googleapis.com/auth/chat.messages.reaction 在 Chat 中查看、添加和删除对消息的回应。
受限
https://www.googleapis.com/auth/chat.messages.reactions.readonly 在 Chat 中查看对消息的回应。
受限
Google Meet  
https://www.googleapis.com/auth/meetings.space.created 允许应用创建、修改和读取有关您的应用创建的会议空间的元数据。
敏感内容
https://www.googleapis.com/auth/meetings.space.readonly 允许应用读取用户有权访问的任何会议空间的元数据。
敏感内容

根据以下定义,上表中的“用量”列指明了每个范围的敏感度:

  • 非敏感 - 这些范围提供最小的授权访问范围,只需要基本的应用验证。如需详细了解此要求,请参阅验证前的准备工作

  • 敏感 - 这些范围可提供对应用用户授权的特定 Google 用户数据的访问权限。您需要进行其他应用验证。如需了解此要求,请参阅请求敏感范围的应用的步骤

  • 受限 - 这些范围可提供对 Google 用户数据的广泛访问权限,并要求您完成受限范围验证流程。如需详细了解此要求,请参阅 Google API 服务:用户数据政策针对特定 API 范围的其他要求。 如果您将受限范围数据存储在服务器上(或进行传输),则必须进行安全评估。

如果您的应用需要访问任何其他 Google API,您也可以添加这些范围。如需详细了解 Google API 范围,请参阅使用 OAuth 2.0 访问 Google API

如需详细了解具体的 OAuth 2.0 范围,请参阅适用于 Google API 的 OAuth 2.0 范围

OAuth 验证

如需使用某些 OAuth 范围,您的应用可能需要完成 Google 的 OAuth 验证流程。如需确定您的应用应在何时进行验证以及需要哪种类型的验证,请参阅 OAuth API 验证常见问题解答。另请参阅 Google 云端硬盘附加服务条款

所需身份验证的类型

本部分介绍了哪些类型的身份验证是必需或支持的,并提供了 Google Workspace Events API 每种方法支持的范围。

对于 Google Chat 事件的订阅,Google Workspace Events API 支持通过用户身份验证和应用身份验证来调用其某些方法。如果一个 API 方法同时支持这两种凭据,则调用中使用的凭据类型会影响返回的结果。例如,如果您使用用户身份验证调用subscriptions.list()方法,API 会返回已通过身份验证的用户可以访问的订阅列表。如果您使用应用身份验证,API 会返回应用可以访问的订阅列表。如需详细了解 Chat 身份验证的类型,请参阅对 Chat 应用和 Google Chat API 请求进行身份验证和授权

下表显示了每种 Google Workspace Events API 方法需要或支持的身份验证范围和类型:

方法 要求进行用户身份验证或支持用户身份验证 支持应用身份验证(仅限 Google Chat 应用) 支持的授权范围
创建订阅

需要每种事件类型支持的范围

  • chat.messages
  • chat.messages.readonly
  • chat.messages.reactions
  • chat.messages.reactions.readonly
  • chat.memberships
  • chat.memberships.readonly
  • chat.spaces
  • chat.spaces.readonly
  • meetings.space.created
  • meetings.space.readonly
获取订阅 采用用户身份验证时,此方法需要一个范围,该范围至少支持一种订阅事件类型

使用应用身份验证(仅限 Google Chat 应用):

  • chat.bot
列出订阅 采用用户身份验证时,此方法需要一个范围,该范围至少支持一种订阅事件类型

使用应用身份验证(仅限 Google Chat 应用):

  • chat.bot
更新订阅

需要每种事件类型支持的范围

  • chat.messages
  • chat.messages.readonly
  • chat.messages.reactions
  • chat.messages.reactions.readonly
  • chat.memberships
  • chat.memberships.readonly
  • chat.spaces
  • chat.spaces.readonly
  • meetings.space.created
  • meetings.space.readonly
重新激活订阅

需要每种事件类型支持的范围

  • chat.messages
  • chat.messages.readonly
  • chat.messages.reactions
  • chat.messages.reactions.readonly
  • chat.memberships
  • chat.memberships.readonly
  • chat.spaces
  • chat.spaces.readonly
  • meetings.space.created
  • meetings.space.readonly
删除订阅 采用用户身份验证时,此方法需要一个范围,该范围至少支持一种订阅事件类型

使用应用身份验证(仅限 Google Chat 应用):

  • chat.bot

范围(按事件类型)

使用用户身份验证调用 Google Workspace Events API 时,必须指定一个或多个与订阅事件类型对应的范围。

下表显示了每种事件类型支持的授权范围:

事件 事件类型 支持的授权范围
Google Chat  
发布或更新消息
  • google.workspace.chat.message.v1.created
  • google.workspace.chat.message.v1.updated
  • chat.messages
  • chat.messages.readonly
添加或删除回应,或更改多个回应。
  • google.workspace.chat.reaction.v1.created
  • google.workspace.chat.reaction.v1.deleted
  • google.workspace.chat.reaction.v1.batchChanged
  • chat.messages.reactions
  • chat.messages.reactions.readonly
创建、更新或移除成员资格,或更改多个成员资格。
  • google.workspace.chat.membership.v1.created
  • google.workspace.chat.membership.v1.updated
  • google.workspace.chat.membership.v1.deleted
  • google.workspace.chat.membership.v1.batchChanged
  • chat.memberships
  • chat.memberships.readonly
更新或删除聊天室
  • google.workspace.chat.space.v1.updated
  • google.workspace.chat.space.v1.deleted
  • chat.spaces
  • chat.spaces.readonly
Google Meet  
会议开始或结束。
  • google.workspace.meet.conference.v2.started
  • google.workspace.meet.conference.v2.ended
  • meetings.space.created
  • meetings.space.readonly
参与者加入或退出会议。
  • google.workspace.meet.participant.v2.joined
  • google.workspace.meet.participant.v2.left
  • meetings.space.created
  • meetings.space.readonly
生成了一条录制内容
  • google.workspace.meet.recording.v2.fileGenerated
  • meetings.space.created
  • meetings.space.readonly
已生成转录内容
  • google.workspace.meet.transcript.v2.fileGenerated
  • meetings.space.created
  • meetings.space.readonly