选择 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 允许 Chat 应用查看对话和发送消息。授予对 Chat 应用可用的所有功能的访问权限。 非敏感
https://www.googleapis.com/auth/chat.memberships 查看、移除 Chat 对话中的成员以及向其中添加成员。
敏感
https://www.googleapis.com/auth/chat.memberships.readonly 查看 Chat 对话中的成员。
敏感
https://www.googleapis.com/auth/chat.app.memberships

以 Chat 应用的身份查看、添加、更新和移除 Chat 对话和聊天室中的成员。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用用户凭据或全网域授权通过此范围进行身份验证。


敏感
https://www.googleapis.com/auth/chat.app.memberships.readonly

以 Chat 应用身份查看 Google Chat 对话和聊天室中的成员。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用此范围通过用户凭据或全网域授权进行身份验证。


敏感
https://www.googleapis.com/auth/chat.spaces 在 Chat 中创建对话和聊天室,以及查看或更新元数据(包括聊天记录设置)。 敏感
https://www.googleapis.com/auth/chat.spaces.readonly 在 Chat 中查看聊天和聊天室。
敏感
https://www.googleapis.com/auth/chat.app.spaces

在 Chat 中以 Chat 应用身份创建对话和聊天室,以及查看或更新元数据(包括聊天记录设置)。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用此范围通过用户凭据或全网域授权进行身份验证。


敏感
https://www.googleapis.com/auth/chat.app.spaces.readonly

以 Chat 应用的身份查看 Google Chat 中的元数据(包括聊天记录设置)。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用此范围通过用户凭据或全网域授权进行身份验证。


敏感
https://www.googleapis.com/auth/chat.messages.reactions 在 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 在 Chat 中查看消息和回应。
受限
https://www.googleapis.com/auth/chat.app.messages.readonly

以 Chat 应用的身份查看 Chat 中的消息和回应。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用此范围通过用户凭据或全网域授权进行身份验证。


受限
https://www.googleapis.com/auth/chat.users.readstate 查看和更新 Chat 中的用户已读状态。
敏感
https://www.googleapis.com/auth/chat.users.readstate.readonly 查看 Chat 中的用户已读状态。
敏感
https://www.googleapis.com/auth/chat.users.availability 在 Chat 中查看和更改有空/忙碌状态。
敏感
https://www.googleapis.com/auth/chat.users.availability.readonly 在 Chat 中查看有空/忙碌状态。
敏感
https://www.googleapis.com/auth/chat.app.all.spaces.readonly

查看与您所属 Google Workspace 组织内所有 Google Chat 聊天室和话题相关的元数据,即使该 Chat 应用不是成员也能查看。

此范围仅支持客户订阅。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用用户凭据或全网域授权通过此范围进行身份验证。

受限
https://www.googleapis.com/auth/chat.app.all.memberships.readonly

查看您所属 Google Workspace 组织内 Google Chat 聊天室和话题的所有成员,即使该 Chat 应用不是成员也能查看。

此范围仅支持客户订阅。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用用户凭据或全网域授权通过此范围进行身份验证。

受限
https://www.googleapis.com/auth/chat.app.all.messages.readonly

查看整个 Google Workspace 组织中的所有消息和回应,即使 Chat 应用不是聊天室或话题的成员也能查看。

此范围仅支持客户订阅。

需要管理员批准。

此范围仅支持使用服务账号进行应用身份验证。您无法使用用户凭据或全网域授权通过此范围进行身份验证。

受限
https://www.googleapis.com/auth/chat.app.all.users.readstate.readonly

查看整个 Google Workspace 组织中所有聊天室和话题中所有用户的上次阅读时间,即使该 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 Workspace Events API 的每种方法支持的范围。

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

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

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

使用用户身份验证时,需要为每种事件类型提供受支持的范围:

  • chat.messages
  • chat.messages.readonly
  • chat.messages.reactions
  • chat.messages.reactions.readonly
  • chat.memberships
  • chat.memberships.readonly
  • chat.spaces
  • chat.spaces.readonly
  • chat.users.readstate
  • chat.users.readstate.readonly
  • chat.users.availability
  • chat.users.availability.readonly
  • drive.file
  • drive
  • drive.readonly
  • drive.metadata
  • drive.metadata.readonly
  • meetings.space.created
  • meetings.space.readonly

通过应用身份验证和管理员批准(仅限 Google Chat 应用),需要为每种事件类型提供受支持的范围:

  • chat.app.memberships
  • chat.app.memberships.readonly
  • chat.app.spaces
  • chat.app.spaces.readonly
  • chat.app.messages.readonly
  • chat.app.all.memberships.readonly
  • chat.app.all.spaces.readonly
  • chat.app.all.messages.readonly
  • chat.app.all.users.readstate.readonly
开始订阅 通过用户身份验证,此方法需要一个至少支持一种事件类型的订阅范围。

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

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

使用应用身份验证(仅限 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
  • chat.users.readstate
  • chat.users.readstate.readonly
  • chat.users.availability
  • chat.users.availability.readonly
  • drive.file
  • drive
  • drive.readonly
  • drive.metadata
  • drive.metadata.readonly
  • meetings.space.created
  • meetings.space.readonly

通过应用身份验证和管理员批准(仅限 Google Chat 应用),需要为每种事件类型提供受支持的范围:

  • chat.app.memberships
  • chat.app.memberships.readonly
  • chat.app.spaces
  • chat.app.spaces.readonly
  • chat.app.messages.readonly
  • chat.app.all.memberships.readonly
  • chat.app.all.spaces.readonly
  • chat.app.all.messages.readonly
  • chat.app.all.users.readstate.readonly
重新激活订阅 —

使用用户身份验证时,需要为每种事件类型提供受支持的范围:

  • chat.messages
  • chat.messages.readonly
  • chat.messages.reactions
  • chat.messages.reactions.readonly
  • chat.memberships
  • chat.memberships.readonly
  • chat.spaces
  • chat.spaces.readonly
  • chat.users.readstate
  • chat.users.readstate.readonly
  • chat.users.availability
  • chat.users.availability.readonly
  • drive.file
  • drive
  • drive.readonly
  • drive.metadata
  • drive.metadata.readonly
  • meetings.space.created
  • meetings.space.readonly

通过应用身份验证和管理员批准(仅限 Chat 应用),需要为每种事件类型提供受支持的范围:

  • chat.app.memberships
  • chat.app.memberships.readonly
  • chat.app.spaces
  • chat.app.spaces.readonly
  • chat.app.messages.readonly
  • chat.app.all.memberships.readonly
  • chat.app.all.spaces.readonly
  • chat.app.all.messages.readonly
  • chat.app.all.users.readstate.readonly
删除订阅 通过用户身份验证,此方法需要一个至少支持一种事件类型的订阅范围。

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

  • chat.bot

按事件类型划分的范围

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

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

事件 事件类型 支持的授权范围
Chat  
发布或更新了消息。
  • google.workspace.chat.message.v1.created
  • google.workspace.chat.message.v1.updated
使用用户身份验证:
  • chat.messages
  • chat.messages.readonly
通过应用身份验证和管理员批准:
  • chat.app.messages.readonly
  • chat.app.all.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
通过应用身份验证和管理员批准:
  • chat.app.messages.readonly
  • chat.app.all.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
通过应用身份验证和管理员批准:
  • chat.app.memberships
  • chat.app.memberships.readonly
  • chat.app.all.memberships.readonly
聊天室已更新或删除。
  • google.workspace.chat.space.v1.updated
  • google.workspace.chat.space.v1.deleted
使用用户身份验证:
  • chat.spaces
  • chat.spaces.readonly
通过应用身份验证和管理员批准:
  • chat.app.spaces
  • chat.app.spaces.readonly
  • chat.app.all.spaces.readonly
用户的聊天室已读状态或话题已读状态已更新。
  • google.workspace.chat.spaceReadState.v1.updated
  • google.workspace.chat.threadReadState.v1.updated
  • google.workspace.chat.spaceReadState.v1.batchUpdated
  • google.workspace.chat.threadReadState.v1.batchUpdated
使用用户身份验证:
  • chat.users.readstate
  • chat.users.readstate.readonly
通过应用身份验证和管理员批准:
  • chat.app.all.users.readstate.readonly
空位已更新。
  • google.workspace.chat.availability.v1.updated
使用用户身份验证:
  • chat.users.availability
  • chat.users.availability.readonly
云端硬盘  
文件被创建、更改、移动、删除、重命名、移至回收站或从回收站中移除。
  • 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.renamed
  • google.workspace.drive.file.v3.trashed
  • google.workspace.drive.file.v3.untrashed
  • drive
  • drive.file
  • drive.readonly
  • drive.metadata
针对文件创建或解决了访问权限提案。
  • google.workspace.drive.accessProposal.v3.created
  • google.workspace.drive.accessProposal.v3.resolved
  • drive
  • drive.file
  • drive.readonly
  • drive.metadata
  • drive.metadata
  • drive.metadata.readonly
文件的审批被取消、完成、创建、重置、审核者发生更改或审核者做出回应。
  • google.workspace.drive.approval.v3.cancelled
  • google.workspace.drive.approval.v3.completed
  • google.workspace.drive.approval.v3.created
  • google.workspace.drive.approval.v3.reset
  • google.workspace.drive.approval.v3.reviewersChanged
  • google.workspace.drive.approval.v3.reviewerResponded
  • drive
  • drive.file
  • drive.readonly
  • drive.metadata
  • drive.metadata
  • drive.metadata.readonly
在文件上创建、删除、修改、重新打开或解决评论。
  • google.workspace.drive.comment.v3.created
  • google.workspace.drive.comment.v3.deleted
  • google.workspace.drive.comment.v3.edited
  • google.workspace.drive.comment.v3.reopened
  • google.workspace.drive.comment.v3.resolved
  • drive
  • drive.file
  • drive.readonly
  • drive.metadata
  • drive.metadata
  • drive.metadata.readonly
在文件上创建、删除或修改回复。
  • google.workspace.drive.reply.v3.created
  • google.workspace.drive.reply.v3.deleted
  • google.workspace.drive.reply.v3.edited
  • drive
  • drive.file
  • drive.readonly
  • drive.metadata
  • drive.metadata
  • drive.metadata.readonly
创建、删除或修改文件的权限。
  • google.workspace.drive.permission.v3.created
  • google.workspace.drive.permission.v3.deleted
  • google.workspace.drive.permission.v3.edited
  • drive
  • drive.file
  • drive.readonly
  • drive.metadata
  • drive.metadata
  • drive.metadata.readonly
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