Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette section contient des instructions spécifiques à l'API Google Play Developer. Consultez le
documentation OAuth2 complète
pour en savoir plus.
Configuration initiale
L'accès à l'API Google Play Android Developer est authentifié à l'aide de la
Serveur Web OAuth 2.0
le flux de travail. Avant de pouvoir utiliser l'API, vous devez configurer une console d'API
créer un ID client et générer un jeton d'actualisation.
Créer un projet dans la console des API
Accédez à la console des API et connectez-vous.
avec votre compte Google Play Console.
Sélectionnez Créer un projet.
Accédez à Services dans le panneau de navigation de gauche.
Activez l'API Google Play Android Developer.
Acceptez les conditions d'utilisation.
Accédez à Accès à l'API dans le panneau de navigation de gauche.
Sélectionnez Créer un ID client OAuth 2.0.
Sur la première page, vous devrez indiquer le nom du produit, mais un logo
n'est pas obligatoire. Notez que vos utilisateurs finaux ne verront pas le nom du produit.
Sur la deuxième page, sélectionnez l'application Web, définissez l'URI de redirection et
Origines JavaScript. Vous pourrez modifier ces deux paramètres ultérieurement.
Sélectionnez Créer un ID client.
Générer un jeton d'actualisation
Tout en étant connecté à votre compte Google Play Console, accédez à la
URI suivant:
Sélectionnez Autoriser l'accès lorsque vous y êtes invité.
Le navigateur sera redirigé vers votre URI de redirection avec un code
. Il doit ressembler à 4/eWdxD7b-YSQ5CNNb-c2iI83KQx19.wp6198ti5Zc7dJ3UXOl0T3aRLxQmbwI.
Échangez ce code contre une paire de jetons d'accès et d'actualisation en envoyant une requête POST
à https://accounts.google.com/o/oauth2/token avec le
les champs suivants sont définis:
grant_type=authorization_code
code=<the code from the previous step>
client_id=<the client ID token created in the APIs Console>
client_secret=<the client secret corresponding to the client ID>
redirect_uri=<the URI registered with the client ID>
Une réponse positive contiendra vos jetons au format JSON:
Une fois que vous avez généré les identifiants client et le jeton d'actualisation, vos serveurs
peuvent accéder à l'API sans connexion active ni intervention humaine.
Utiliser le jeton d'accès
Les serveurs peuvent appeler l'API en transmettant le jeton d'accès dans le
En-tête Authorization de la requête:
Authorization: Bearer oauth2-token
Utiliser le jeton d'actualisation
Chaque jeton d'accès n'est valide que pendant une courte période. Une fois que le jeton d'accès actuel
expire, le serveur doit utiliser le jeton d'actualisation pour en obtenir un nouveau. À faire
envoyez une requête POST à https://accounts.google.com/o/oauth2/token avec
les champs suivants sont définis:
grant_type=refresh_token
client_id=<the client ID token created in the APIs Console>
client_secret=<the client secret corresponding to the client ID>
refresh_token=<the refresh token from the previous step>
Les réponses positives contiennent un autre jeton d'accès:
Le jeton d'actualisation permet ainsi à un serveur Web d'accéder à l'API en continu
sans nécessiter une connexion active à un compte Google.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003eAccess to the Google Play Android Developer API is authenticated using the OAuth 2.0 Web Server flow and requires initial configuration.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, developers need to set up an APIs Console project, create a client ID, and generate a refresh token.\u003c/p\u003e\n"],["\u003cp\u003eServers can access the API using short-lived access tokens passed in the Authorization header, requiring refresh tokens for continued access.\u003c/p\u003e\n"],["\u003cp\u003eRefresh tokens enable web servers to maintain API access without an active Google account login, by exchanging them for new access tokens.\u003c/p\u003e\n"]]],["First, create an APIs Console project, enable the *Google Play Android Developer API*, and generate an OAuth 2.0 client ID. Next, navigate to a specified URI to receive a code, then exchange this code for an access and refresh token by sending a POST request to a specific URL with necessary details. To access the API, pass the access token in the request header. When expired, obtain a new access token by sending a POST request with the refresh token.\n"],null,["# Authorization\n\nThis section contains instructions specific to the Google Play Developer API. See the\n[full OAuth2 documentation](https://developers.google.com/accounts/docs/OAuth2)\nfor more details.\n\nInitial configuration\n---------------------\n\nAccess to the Google Play Android Developer API is authenticated using the\n[OAuth 2.0 Web Server](https://developers.google.com/accounts/docs/OAuth2WebServer)\nflow. Before you can use the API, you will need to set up an APIs Console\nproject, create a client ID and generate a refresh token.\n\n### Creating an APIs Console project\n\n1. Go to the [APIs Console](https://code.google.com/apis/console) and log in with your Google Play Console account.\n2. Select **Create project**.\n3. Go to **Services** in the left-hand navigation panel.\n4. Turn the *Google Play Android Developer API* on.\n5. Accept the Terms of Service.\n6. Go to **API Access** in the left-hand navigation panel.\n7. Select **Create an OAuth 2.0 client ID** .\n - On the first page, you will need to fill in the product name, but a logo is not required. Note that your end users will not see the product name.\n - On the second page, select web application and set the redirect URI and Javascript origins. Both of these settings can be changed later.\n8. Select **Create client ID**.\n\n### Generating a refresh token\n\n1. While logged in with your Google Play Console account, go to the following URI: \n\n ```\n https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=...&client_id=...\n ```\n | **Note:** the `redirect_uri` parameter must match the value registered with the client ID exactly, including the trailing backslash, if present.\n2. Select **Allow access** when prompted.\n3. The browser will be redirected to your redirect URI with a `code` parameter, which will look similar to `4/eWdxD7b-YSQ5CNNb-c2iI83KQx19.wp6198ti5Zc7dJ3UXOl0T3aRLxQmbwI`.\n4. Exchange this code for an access and refresh token pair by sending a POST request to `https://accounts.google.com/o/oauth2/token` with the following fields set: \n\n ```\n grant_type=authorization_code\n code=\u003cthe code from the previous step\u003e\n client_id=\u003cthe client ID token created in the APIs Console\u003e\n client_secret=\u003cthe client secret corresponding to the client ID\u003e\n redirect_uri=\u003cthe URI registered with the client ID\u003e\n ```\n A successful response will contain your tokens in JSON format: \n\n ```\n {\n \"access_token\" : \"ya29.ZStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM\",\n \"token_type\" : \"Bearer\",\n \"expires_in\" : 3600,\n \"refresh_token\" : \"1/zaaHNytlC3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho\"\n }\n ```\n\nAccessing the API\n-----------------\n\nOnce you have generated the client credentials and refresh token, your servers\ncan access the API without an active login or human intervention.\n\n### Using the access token\n\nServers can make calls to the API by passing the access token in the\n`Authorization` header of the request: \n\n```\nAuthorization: Bearer oauth2-token\n```\n\n### Using the refresh token\n\nEach access token is only valid for a short time. Once the current access token\nexpires, the server will need to use the refresh token to get a new one. To do\nthis, send a POST request to `https://accounts.google.com/o/oauth2/token` with\nthe following fields set: \n\n```\ngrant_type=refresh_token\nclient_id=\u003cthe client ID token created in the APIs Console\u003e\nclient_secret=\u003cthe client secret corresponding to the client ID\u003e\nrefresh_token=\u003cthe refresh token from the previous step\u003e\n```\n\nA successful response will contain another access token: \n\n```\n{\n \"access_token\" : \"ya29.AHES3ZQ_MbZCwac9TBWIbjW5ilJkXvLTeSl530Na2\",\n \"token_type\" : \"Bearer\",\n \"expires_in\" : 3600,\n}\n```\n\nThe refresh token thus allows a web server continual access to the API without\nrequiring an active login to a Google account."]]