重要資訊:我們目前不接受新的 Play EMM API 註冊。
瞭解詳情。
對要求進行授權
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
當您的應用程式要求私人資料時,這個要求必須取得可存取該資料的已驗證使用者的授權。
當您的應用程式要求公開資料時,這個要求不須取得授權,但須要附有 ID,例如 API 金鑰。
您的應用程式傳送至 Google Play EMM API 的每項要求都必須包含授權權杖。這個權杖也可讓 Google 識別您的應用程式。
關於授權通訊協定
您的應用程式必須使用 OAuth 2.0 對要求進行授權,系統不支援其他授權通訊協定。如果您的應用程式採用使用 Google 帳戶登入功能,系統會為您處理部分授權事項。
使用 OAuth 2.0 對要求進行授權
所有傳送至 Google Play EMM API 的要求都必須獲得已驗證使用者的授權。
OAuth 2.0 授權程序 (或「流程」) 的細節會根據您編寫的應用程式類型而有所不同。下列一般程序適用於所有應用程式類型:
- 建立應用程式後,請透過 Google API 控制台註冊應用程式。接著 Google 會向您提供稍後需要的資訊,例如用戶端 ID 和用戶端密碼。
- 在 Google API 控制台中啟用 Google Play EMM API。(如果 API 控制台裡沒有列出該 API,則可略過這個步驟)。
- 當應用程式需要存取使用者資料時,會向 Google 要求特定的存取範圍。
- Google 會向使用者顯示同意畫面,請對方授權您的應用程式要求部分資料。
- 如果使用者同意,Google 即會授予短期存取權杖給您的應用程式。
- 您的應用程式向使用者要求資料,並且在要求中附上存取權杖。
- 如果 Google 判定您的要求與權杖有效,便會傳回您要求的資料。
部分流程包含額外步驟,例如使用「更新權杖」來取得新的存取權杖。如要進一步瞭解各類應用程式的流程,請參閱 Google 的 OAuth 2.0 說明文件。
以下是 Google Play EMM API 的 OAuth 2.0 範圍資訊:
https://www.googleapis.com/auth/androidenterprise
如要透過 OAuth 2.0 要求存取權,您的應用程式需要範圍資訊,以及 Google 在您註冊應用程式時提供的資訊 (例如用戶端 ID 和用戶端密碼)。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-05-08 (世界標準時間)。
[null,null,["上次更新時間:2025-05-08 (世界標準時間)。"],[[["\u003cp\u003eRequests for private data require authorization from an authenticated user with access, while public data requests need an identifier like an API key but no authorization.\u003c/p\u003e\n"],["\u003cp\u003eAll requests to the Google Play EMM API must include an OAuth 2.0 authorization token for authentication and application identification.\u003c/p\u003e\n"],["\u003cp\u003eApplications must use OAuth 2.0 for authorization, involving registration, API activation, scope definition, user consent, and access token acquisition.\u003c/p\u003e\n"],["\u003cp\u003eThe OAuth 2.0 scope for the Google Play EMM API is \u003ccode\u003ehttps://www.googleapis.com/auth/androidenterprise\u003c/code\u003e, and applications need this scope along with registration information like client ID and secret for access.\u003c/p\u003e\n"]]],[],null,["# Authorize Requests\n\nWhen your application requests private data, the request must be authorized by an authenticated user who has access to that data.\n\nWhen your application requests public data, the request doesn't need to be authorized, but does need to be accompanied by an identifier, such as an API key.\n\nEvery request your application sends to the Google Play EMM API must include an authorization token. The token also identifies your application to Google.\n\nAbout authorization protocols\n-----------------------------\n\nYour application must use [OAuth 2.0](https://developers.google.com/identity/protocols/OAuth2) to authorize requests. No other authorization protocols are supported. If your application uses [Sign In With Google](https://developers.google.com/identity/gsi/web), some aspects of authorization are handled for you.\n\nAuthorizing requests with OAuth 2.0\n-----------------------------------\n\nAll requests to the Google Play EMM API must be authorized by an authenticated user.\n\nThe details of the authorization process, or \"flow,\" for OAuth 2.0 vary somewhat depending on what kind of application you're writing. The following general process applies to all application types:\n\n1. When you create your application, you register it using the [Google API Console](https://console.cloud.google.com/). Google then provides information you'll need later, such as a client ID and a client secret.\n2. Activate the Google Play EMM API in the Google API Console. (If the API isn't listed in the API Console, then skip this step.)\n3. When your application needs access to user data, it asks Google for a particular **scope** of access.\n4. Google displays a **consent screen** to the user, asking them to authorize your application to request some of their data.\n5. If the user approves, then Google gives your application a short-lived **access token**.\n6. Your application requests user data, attaching the access token to the request.\n7. If Google determines that your request and the token are valid, it returns the requested data.\n\nSome flows include additional steps, such as using **refresh tokens** to acquire new access tokens. For detailed information about flows for various types of applications, see Google's [OAuth 2.0 documentation](https://developers.google.com/identity/protocols/OAuth2).\n\nHere's the OAuth 2.0 scope information for the Google Play EMM API: \n\n```\nhttps://www.googleapis.com/auth/androidenterprise\n```\n\nTo request access using OAuth 2.0, your application needs the scope information, as well as\ninformation that Google supplies when you register your application (such as the client ID and the\nclient secret)."]]