本文件包含 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 |
這個範圍只能擷取日曆資源。 |