應用程式授權
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以利用 Google Play 提供的授權服務,針對在 Google Play 發布的應用程式強制執行授權政策。透過 Google Play 授權服務,您的應用程式就能在執行階段向 Google Play 提出查詢,以便取得目前使用者的授權狀態,再視情況允許或拒絕使用者進一步使用應用程式。
您可以使用這項服務為每個應用程式套用靈活彈性的授權政策,讓每個應用程式都能依照最適合的方式強制執行授權。如有需要,可依據從 Google Play 取得的授權狀態對應用程式套用自訂限制。
例如,應用程式可以檢查授權狀態,然後套用自訂限制,讓使用者在特定有效期內在未經授權的情況下執行應用程式。除其他限制外,應用程式也可以將使用範圍限制為特定裝置。
授權服務是控管應用程式存取權的安全做法。應用程式檢查授權狀態時,Google Play 伺服器會使用金鑰組簽署授權狀態回應,而此金鑰組與應用程式之間具有唯一的對應關係。雖然應用程式可以將公開金鑰儲存在其編譯的 .apk
檔案中,但在信任的伺服器上驗證授權狀態回應更加安全。
凡是透過 Google Play 發布的應用程式都可以使用 Google Play 授權服務。無需使用特殊帳戶,也不需要註冊。此外,由於這項服務並未使用專屬的架構 API,因此您可以為任何 API 級別為 3 或更高級別的應用程式新增授權。
注意:Google Play 授權服務主要針對付費應用程式,用於驗證目前的使用者是否確實在 Google Play 中支付了應用程式的費用。不過,任何應用程式 (包括免費應用程式) 都可以透過授權服務來啟動 APK 擴充檔案下載作業。在這種情況下,您的應用程式傳送給授權服務的要求並不是檢查使用者是否已支付應用程式的費用,而是要求擴充檔案的網址。如需有關下載應用程式擴充檔案的資訊,請參閱 APK 擴充檔案指南。
如要進一步瞭解 Google Play 的應用程式授權服務,並開始將服務整合至您的應用程式,請參閱下列文件:
- 授權總覽
- 說明服務的運作方式,以及常見的授權實作方式。
- 設定授權
- 說明如何設定 Google Play 帳戶、開發環境和測試環境,以便將授權新增至應用程式。
- 在應用程式中加入伺服器端授權驗證
- 提供為應用程式新增伺服器端授權驗證的逐步指南。
- 授權參考資料
- 提供授權程式庫類別與服務回應代碼的詳細資訊。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# App Licensing\n\nGoogle Play offers a licensing service that lets you enforce licensing policies for\napplications that you publish on Google Play. With Google Play Licensing, your application can\nquery Google Play at run time to obtain the licensing status for the current user, then allow or\ndisallow further use as appropriate.\n\nUsing the service, you can apply a flexible licensing policy on an application-by-application\nbasis---each application can enforce licensing in the way most appropriate for it. If necessary,\nan application can apply custom constraints based on the licensing status obtained from Google Play.\nFor example, an application can check the licensing status and then apply custom constraints\nthat allow the user to run it unlicensed for a specific validity period. An application can also\nrestrict use of the application to a specific device, in addition to any other constraints.\n\nThe licensing service is a secure means of controlling access to your applications. When an\napplication checks the licensing status, the Google Play server signs the licensing status\nresponse using a key pair that is uniquely associated with the application. Although it's possible\nfor your application to store the public key in its compiled `.apk` file, it's much\nsafer to verify the licensing status response on a server that you trust.\n\nAny application that you publish through Google Play can use the Google Play Licensing\nservice. No special account or registration is needed. Additionally, because the service uses no\ndedicated framework APIs, you can add licensing to any application that uses a minimum API level of\n3 or higher.\n\n**Note:** The Google Play Licensing service is primarily intended\nfor paid applications that wish to verify that the current user did in fact pay for the application\non Google Play. However, any application (including free apps) may use the licensing service\nto initiate the download of an APK expansion file. In which case, the request that your application\nsends to the licensing service is not to check whether the user paid for the app, but to request the\nURL of the expansion files. For information about downloading expansion files for your application,\nread the guide to [APK Expansion Files](/google/play/expansion-files).\n\nTo learn more about Google Play's application licensing service and start integrating it into\nyour applications, read the following documents:\n\n**[Licensing\nOverview](/google/play/licensing/overview)**\n: Describes how the service works and what a typical licensing implementation looks\n like.\n\n**[Setting Up for\nLicensing](/google/play/licensing/setting-up)**\n: Explains how to set up your Google Play account, development environment, and\n testing environment in order to add licensing to your app.\n\n**[Adding\nServer-Side License Verification to Your App](/google/play/licensing/server-side-verification)**\n: Provides a step-by-step guide to add server-side licensing verification to your application.\n\n**[Licensing\nReference](/google/play/licensing/licensing-reference)**\n: Provides detailed information about the licensing library's classes and the service response\n codes."]]