选择 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 应用查看对话和发送消息。授予对聊天应用可用的所有功能的访问权限。 非敏感
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.reaction 在 Chat 中查看、添加和删除对消息的回应。
敏感
https://www.googleapis.com/auth/chat.messages.reactions.readonly 在 Chat 中查看对消息的回应。
敏感
https://www.googleapis.com/auth/chat.messages 查看、撰写、发送、更新和删除消息,以及添加、查看和删除对消息的回应。 受限
https://www.googleapis.com/auth/chat.messages.readonly 在 Google Chat 中查看消息和回应。
受限
Google 云端硬盘  
https://www.googleapis.com/auth/drive.file 创建新的云端硬盘文件,或修改您使用应用打开的现有文件,或用户在使用 Google Picker API 或应用的文件选择器时与应用共享的文件。 非敏感
https://www.googleapis.com/auth/drive 查看和管理您的所有云端硬盘文件。 受限
https://www.googleapis.com/auth/drive.readonly 查看和下载您的所有云端硬盘文件。 受限
https://www.googleapis.com/auth/drive.metadata 查看和管理您云端硬盘中文件的元数据。 受限
https://www.googleapis.com/auth/drive.metadata.readonly 查看云端硬盘中文件的元数据。 受限
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 范围可能需要您的应用通过 OAuth 应用验证帮助中心。 请阅读 OAuth 应用常见问题解答,确定您的应用何时应完成验证以及需要哪种类型的验证。另请参阅《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
  • drive.file
  • drive
  • drive.readonly
  • drive.metadata
  • drive.metadata.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
  • drive.file
  • drive
  • drive.readonly
  • drive.metadata
  • drive.metadata.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
  • drive.file
  • drive
  • drive.readonly
  • drive.metadata
  • drive.metadata.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
  • chat.messages
  • chat.messages.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 云端硬盘  
文件被创建、更改、移动、删除、放入回收站或从回收站中移除。
  • google.workspace.drive.file.v3.added
  • google.workspace.drive.file.v3.moved
  • google.workspace.drive.file.v3.contentChanged
  • google.workspace.drive.file.v3.deleted
  • google.workspace.drive.file.v3.trashed
  • google.workspace.drive.file.v3.untrashed
  • drive
  • drive.file
  • drive.metadata
针对文件创建或解决了访问提案
  • google.workspace.drive.accessProposal.v3.created
  • google.workspace.drive.accessProposal.v3.resolved
  • drive
  • drive.file
  • drive.metadata
  • drive.metadata
  • drive.metadata.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