本文包含 Directory API 專屬的授權和驗證資訊。閱讀本文前,請務必參閱「瞭解驗證和授權」一文,瞭解 Google Workspace 的一般驗證和授權資訊。
設定 OAuth 2.0 授權
設定 OAuth 同意畫面並選擇範圍,定義要向使用者和應用程式審查人員顯示哪些資訊,並註冊應用程式,以便日後發布。
Directory API 範圍
如要定義授予應用程式的存取權層級,您必須識別並宣告授權範圍。授權範圍是 OAuth 2.0 URI 字串,其中包含 Google Workspace 應用程式名稱、應用程式存取的資料類型,以及存取層級。「範圍」是指應用程式要求處理 Google Workspace 資料的權限,包括使用者的 Google 帳戶資料。
安裝應用程式時,系統會要求使用者驗證應用程式使用的範圍。一般來說,您應盡可能選擇最狹隘的範圍,並避免要求應用程式不需要的範圍。使用者更願意授予明確說明的有限範圍存取權。
Directory API 支援下列範圍:
裝置的範圍 | 意義 |
---|---|
https://www.googleapis.com/auth/admin.directory.device.chromeos |
全域範圍,可存取所有 Chrome 裝置作業。 |
https://www.googleapis.com/auth/admin.directory.device.chromeos.readonly |
僅擷取 Chrome 裝置的範圍。 |
https://www.googleapis.com/auth/admin.directory.device.mobile |
全域範圍,可存取所有行動裝置作業。 |
https://www.googleapis.com/auth/admin.directory.device.mobile.readonly |
僅限擷取行動裝置的範圍 |
https://www.googleapis.com/auth/admin.directory.device.mobile.action |
在行動裝置上執行動作的作業範圍。 |
群組、群組別名和群組成員的範圍 | 意義 |
https://www.googleapis.com/auth/admin.directory.group.member |
存取所有群組成員角色和資訊作業的範圍。 |
https://www.googleapis.com/auth/admin.directory.group.member.readonly |
僅擷取群組成員角色和資訊的範圍。 |
https://www.googleapis.com/auth/admin.directory.group |
全域範圍:可存取所有群組作業,包括群組別名和成員。 |
https://www.googleapis.com/auth/admin.directory.group.readonly |
僅限擷取群組、群組別名和成員資訊的範圍。 |
機構單位的範圍 | 意義 |
https://www.googleapis.com/auth/admin.directory.orgunit |
可存取所有機構單位作業的全域範圍。 |
https://www.googleapis.com/auth/admin.directory.orgunit.readonly |
僅擷取機構單位的範圍。 |
使用者和使用者別名的權限 | 意義 |
https://www.googleapis.com/auth/admin.directory.user |
可存取所有使用者和使用者別名作業的全球範圍。 |
https://www.googleapis.com/auth/admin.directory.user.readonly |
僅擷取使用者或使用者別名的權限。 |
https://www.googleapis.com/auth/admin.directory.user.alias |
存取所有使用者別名作業的範圍。 |
https://www.googleapis.com/auth/admin.directory.user.alias.readonly |
僅限於擷取使用者別名的範圍。 |
使用者安全性功能的權限 | 意義 |
https://www.googleapis.com/auth/admin.directory.user.security |
存取所有應用程式專屬密碼、OAuth 權杖和驗證碼作業的範圍。 |
角色管理的範圍 | 意義 |
https://www.googleapis.com/auth/admin.directory.rolemanagement |
所有角色管理作業的範圍,包括建立角色和角色指派。 |
https://www.googleapis.com/auth/admin.directory.rolemanagement.readonly |
取得及列出角色、權限和角色指派的範圍。 |
自訂使用者結構定義的範圍 | 意義 |
https://www.googleapis.com/auth/admin.directory.userschema |
存取所有自訂使用者架構作業的範圍。 |
https://www.googleapis.com/auth/admin.directory.userschema.readonly |
僅擷取自訂使用者結構定義的範圍。 |
客戶的權限 | 意義 |
https://www.googleapis.com/auth/admin.directory.customer |
存取所有客戶作業的範圍。 |
https://www.googleapis.com/auth/admin.directory.customer.readonly |
僅限擷取客戶。 |
網域的範圍 | 意義 |
https://www.googleapis.com/auth/admin.directory.domain |
存取所有網域作業的範圍。 |
https://www.googleapis.com/auth/admin.directory.domain.readonly |
僅限擷取網域的範圍。 |
日曆資源的範圍 | 意義 |
https://www.googleapis.com/auth/admin.directory.resource.calendar |
可存取所有日曆資源作業的範圍。 |
https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly |
僅擷取日曆資源的範圍。 |