您需要使用 OAuth 客户端或服务账号来配置对 Google Play Developer API 的访问权限。在大多数情况下,您都应当使用服务账号来访问此 API。
服务账号必须在安全的环境(例如您的服务器)中使用。您需要妥善管理服务账号凭证,避免将其泄露给任何无权使用该 API 的人员。
如果您需要代表个人用户访问该 API,您应当使用 OAuth 客户端 ID。例如,如果您的网站需要代表用户从网页客户端访问 Google Play Developer API,那么您可以使用客户端 ID。系统会使用用户的 Google 账号(而不是服务账号)对用户进行身份验证。这样,您就可以代表用户进行 API 调用,而不会影响服务账号凭证的安全。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eYou need to set up API access in the Google Play Console and Google Cloud Console to use the Google Play Developer API.\u003c/p\u003e\n"],["\u003cp\u003eA service account is generally recommended for accessing the API, while OAuth clients are used for individual user access.\u003c/p\u003e\n"],["\u003cp\u003eGrant the service account necessary permissions in the Google Play Console to enable API functionality.\u003c/p\u003e\n"],["\u003cp\u003eTo find your Developer ID, check the URL of any page in the Google Play Console, such as the API access page.\u003c/p\u003e\n"],["\u003cp\u003eExplore specialized APIs and client libraries for specific tasks and programmatic access.\u003c/p\u003e\n"]]],["To access the Google Play Developer API, begin by creating a Google Cloud Project and enabling the Google Play Developer API within it. Then, configure access via a service account for secure server-side access, or an OAuth client for individual user access. For service accounts, create one in Google Cloud Console and invite it as a user in Google Play Console, granting necessary permissions. For OAuth clients, create an OAuth consent screen and then an OAuth client ID. Finally, you can retrieve your unique developer id from the Google Play Console URL.\n"],null,["# Getting Started\n\n| **Note:** You no longer need to link your developer account to a Google Cloud Project in order to access the Google Play Developer API.\n\nBefore you can start making API calls, you need to set up API access to your\nGoogle Play Developer Account. This involves changes in both the\nGoogle Play Console and Google Cloud Console. The following instructions\nexplain the steps needed to start using the Google Play Developer API.\n\n1. Create a Google Cloud Project.\n2. Enable the Google Play Developer API for your Google Cloud Project.\n3. Set up a service account with appropriate Google Play Console permissions to access the Google Play Developer API.\n\nCreate a Google Cloud Project\n-----------------------------\n\nYou can skip this step if you already have a Google Cloud Project\nyou want to use.\n\nCreate a project in the\n[Google Cloud Console](https://console.cloud.google.com/projectcreate).\n\nFor further information on Google Cloud Projects,\nrefer to [Creating and managing projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\nEnable the API\n--------------\n\nOnce you have set up the Google Cloud Project, you need to enable\nthe Google Play Developer API for this project.\n\nTo enable Google Play Developer API:\n\n1. Go to the [Google Play Developer API page](https://console.developers.google.com/apis/api/androidpublisher.googleapis.com/) in Google Cloud Console.\n2. Click **Enable**.\n\nConfigure OAuth and Service Accounts\n------------------------------------\n\nYou need to configure access to the Google Play Developer API with an OAuth client or\na service account. In most cases, you should use a service account\nto access the API.\n\nService accounts must be used in a secure environment, such as your server.\nThe service account credentials need to be securely managed so they are not\nrevealed to anyone that is not authorized to use the API.\n\nThe OAuth Client ID should be used if you need to access the API on behalf\nof an individual user. For example, if your website needs to access the\nGoogle Play Developer API from the web client on behalf of the user, you can use the\nClient ID. The user will be authenticated with their Google account instead\nof the service account. This allows you to make API calls on behalf of a user\nwithout compromising service account credentials.\n\n- Service account: A secure software service will access the API (most common)\n- OAuth clients: A user will access the API\n\n### Use a service account\n\nYou can create a [service account](/accounts/docs/OAuth2ServiceAccount) from\nthe Google Play Console.\n\n1. In the Google Cloud Console go to [Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts).\n2. Click **Create service account** and follow the steps.\n3. Go to the [Users \\& Permissions](https://play.google.com/console/users-and-permissions) page on the Google Play Console.\n4. Click **Invite new users**.\n5. Put an email address for your service account in the email address\n field and grant the necessary rights to perform actions.\n\n To use the Google Play Billing APIs, you must grant the following permissions:\n - *View financial data, orders, and cancellation survey responses*\n - *Manage orders and subscriptions*\n6. Click **Invite user**.\n\nAt this point, you should be able to access the Google Play Developer API through the\nservice account. For more information, see [Using OAuth 2.0 for Server to Server\nApplications](/accounts/docs/OAuth2ServiceAccount).\n\n### Use OAuth clients\n\nYou can allow users to perform actions using the API under their own credentials\nusing an [OAuth](https://developers.google.com/accounts/docs/OAuth2) client.\nA user's actions are limited to those permitted via the\n[Users and permissions](https://play.google.com/console/users-and-permissions)\npage on the Google Play Console.\n\nBefore creating OAuth clients, you need to configure branding information for\nyour product. For more information, see [Setting up your OAuth consent screen](https://support.google.com/cloud/answer/10311615).\n\n1. In the Google Cloud Console, go to [OAuth consent screen page](https://console.cloud.google.com/apis/credentials/consent).\n2. Follow the steps to create OAuth consent screen.\n\nTo create an OAuth client:\n\n1. In the Google Cloud Console, go to [Credentials](https://console.cloud.google.com/apis/credentials).\n2. Click Create Credentials \\\u003e OAuth client ID.\n3. Choose your application type and follow the instructions.\n\nAdditional information\n----------------------\n\nUse the following tips and tricks to help you get started with API usage on\nGoogle Play.\n\n### Obtain your Developer ID\n\nSome APIs require you to provide a Google Play Console Developer ID. This\nis a long number that was assigned when your Google Play Developer Account\nwas created. Your Developer ID can be found in the URL of almost any page on the\nGoogle Play Console, such as the\n[API access](https://play.google.com/console/api-access) page.\n\nFor example, consider the Google Play Console URL: \n\n https://play.google.com/console/developers/1234567890123456789/api-access\n\nIn the URL above, the Developer ID would be `1234567890123456789`.\n\n**Note:** If an app is transferred from one Google Play Developer Account\nto another, the Developer ID associated with that app will change. This means\nthat after the transfer completes, you must use the Developer ID for the new\nGoogle Play Developer Account account in API calls for that app.\n\n### Specialized APIs\n\nThe Google Play Developer API contains several specialized APIs that allow\nyou to perform specific types of analysis on your app:\n\n[Reply to Reviews API](/android-publisher/reply-to-reviews)\n: Allows you to view user feedback for your app and reply to this feedback.\n\n[Voided Purchases API](/android-publisher/voided-purchases)\n: Allows you to revoke access to in-app products associated with purchases that\n a user has voided.\n\n### Client libraries\n\nWe have provided client libraries you can use to programmatically\naccess the REST APIs. For more information, see [Client Libraries and Code\nSamples](/android-publisher/libraries)."]]