選擇 Google Workspace Events API 範圍

本文件包含 Google Workspace Event API 專屬的授權和驗證資訊。閱讀本文件前,請務必參閱「瞭解驗證和授權」一文,瞭解 Google Workspace 的一般驗證和授權資訊。

設定授權所需的 OAuth 2.0

設定 OAuth 同意畫面並選擇範圍,定義要向使用者顯示的資訊及應用程式審查者,並註冊應用程式以供日後發布。

Google Workspace Event API 範圍

如要定義授予應用程式的存取權層級,您必須識別並宣告授權範圍。授權範圍是 OAuth 2.0 URI 字串,包含 Google Workspace 應用程式名稱、應用程式存取的資料類型,以及存取層級。「範圍」是應用程式要求處理 Google Workspace 資料的要求,包括使用者的 Google 帳戶資料。

應用程式安裝完畢後,系統會要求使用者驗證應用程式使用的範圍。一般而言,您應選擇盡可能縮小的範圍,並避免要求應用程式不需要的範圍。使用者能夠更順利地授予描述過明確、有限範圍的存取權。

如果可以,建議您使用非機密範圍,因為這個範圍可授予個別檔案的存取權範圍,並限制應用程式所需的特定功能存取權。

Google Workspace Event API 會使用支援訂閱的 Google Workspace 應用程式提供的範圍。如果您的應用程式已經使用訂閱項目所需的範圍,您不必新增其他範圍,即可使用 Google Workspace Event API。

下表列出 Google Workspace Event 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 Event API 每種方法的支援範圍。

如果是訂閱 Google Chat 事件,Google WorkspaceEvents API 同時支援使用者和應用程式驗證,以呼叫其部分方法。如果 API 方法同時支援這兩種憑證,則呼叫中使用的憑證類型會影響傳回的結果。舉例來說,如果您透過使用者驗證機制呼叫 subscriptions.list() 方法,API 就會傳回已驗證使用者可存取的訂閱項目清單。如果您使用應用程式驗證功能,API 會傳回應用程式可存取的訂閱項目清單。如要進一步瞭解 Chat 驗證的類型,請參閱「驗證及授權 Chat 應用程式和 Google Chat API 要求」。

下表列出每個 Google Workspace Event 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 Event 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