Utiliser les comptes de service OAuth 2.0 avec l'API Manufacturer Center
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Les comptes de service sont des comptes Google spéciaux permettant aux applications d'accéder aux API Google de manière automatisée via OAuth 2.0. Un compte de service utilise un flux OAuth 2.0 qui ne nécessite aucune autorisation supplémentaire. Il utilise à la place un fichier de clé auquel seule votre application peut accéder. Ce guide explique comment accéder à l'API Manufacturer Center à l'aide des comptes de service.
Procédure d'utilisation d'un Service Account pour accéder à l'API Manufacturer Center
Générez des identifiants de compte de service ou accédez aux identifiants publics que vous avez déjà générés. Vous devez créer un ID client OAuth 2.0 et obtenir un fichier de clé privée *.json:
Sélectionnez un projet dans le menu déroulant en haut de la page. Si vous n'en avez pas encore, créez-en un en cliquant sur Créer un projet.
Si vous n'avez pas encore activé l'API Manufacturer Center pour ce projet, recherchez-la dans la liste des API Google et activez-la.
Dans la barre latérale de gauche, sélectionnez Credentials (Identifiants).
Pour configurer un compte de service, sélectionnez Créer des identifiants, puis Clé de compte de service.
Sur la page suivante, sélectionnez Nouveau compte de service dans la liste déroulante.
Attribuez un nom au nouveau compte de service. Il servira également de nom d'utilisateur par défaut pour l'ID de compte de service. Mémorisez l'ID du compte de service, car vous l'utiliserez plus tard.
Sélectionnez le type de clé JSON, puis cliquez sur Créer.
Le bouton Create (Créer) devient Creating... (Création). Une fois la génération de la clé terminée, la clé privée est automatiquement téléchargée sous forme de fichier *.json.
Vous êtes redirigé vers la page "Identifiants". Vous devriez voir le nouveau compte de service dans la liste des clés de compte de service de votre compte.
Ajoutez le nouveau compte de service en tant qu'utilisateur à votre compte Manufacturer Center.
Si vous êtes un développeur tiers, vous devez demander à votre client d'effectuer cette étape pour vous.
Accédez à la liste "Utilisateurs" dans les paramètres de votre compte Manufacturer Center.
Cliquez sur le bouton "+ Utilisateur" et utilisez l'ID de compte de service comme adresse e-mail du nouvel utilisateur.
Remplissez le formulaire avec l'ID de compte de service, puis sélectionnez le ou les rôles utilisateur souhaités. Vous devez en choisir au moins un, et l'utilisation du service Accounts nécessite le rôle d'administrateur.
Si vous n'avez pas noté l'ID de compte de service précédemment, accédez à la page d'administration Comptes de service et sélectionnez le projet que vous avez créé.
Cliquez sur le bouton Save (Enregistrer). Vous êtes redirigé vers la liste des utilisateurs. L'ID de compte de service doit apparaître avec le ou les rôles utilisateur choisis.
Répétez la procédure pour tous les autres comptes de service que vous souhaitez ajouter.
Affichez les utilisateurs existants du compte de service en accédant à l'onglet "Utilisateurs". Il s'agit d'utilisateurs dont l'adresse e-mail se termine par "gserviceaccount.com".
Vous pouvez désormais accéder à votre compte Manufacturer Center à l'aide du compte de service via le flux Identifiants par défaut de l'application Google ou directement via le flux du compte de service. Les exemples de l'API Manufacturer Center montrent comment utiliser ces deux flux pour les identifiants de compte de service dans chaque langage de programmation compatible. Consultez les exemples de code pour tester votre nouveau compte de service et connaître les modifications à apporter pour utiliser les comptes de service dans votre propre code.
Questions fréquentes
Puis-je me connecter à l'interface utilisateur Web de Manufacturer Center avec mon compte de service ?
Non, les comptes de service ne sont pas des comptes Google standards et ne peuvent pas accéder à l'interface utilisateur Web de Manufacturer Center.
À quelle fréquence dois-je actualiser les jetons d'accès au compte de service ?
Les jetons d'accès expirent une heure après leur émission par le serveur d'autorisation Google OAuth 2.0. Lorsqu'un jeton d'accès expire, l'application doit récupérer un autre jeton d'accès à l'aide de la bibliothèque cliente.
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/08/31 (UTC).
[null,null,["Dernière mise à jour le 2025/08/31 (UTC)."],[[["\u003cp\u003eService accounts enable applications to programmatically access the Manufacturer Center API using OAuth 2.0 without user intervention.\u003c/p\u003e\n"],["\u003cp\u003eTo use a service account, generate service account credentials in Google Cloud Console, enable the Manufacturer Center API, and download the JSON key file.\u003c/p\u003e\n"],["\u003cp\u003eAdd the service account as a user to your Manufacturer Center account with the appropriate role for API access.\u003c/p\u003e\n"],["\u003cp\u003eAccess your Manufacturer Center account programmatically using Google Application Default Credentials or the service account flow, referencing the provided samples.\u003c/p\u003e\n"],["\u003cp\u003eService accounts cannot be used to log into the Manufacturer Center web user interface but solely for API interaction.\u003c/p\u003e\n"]]],[],null,["# Using OAuth 2.0 service accounts with the Manufacturer Center API\n\nService accounts are special Google accounts that can be used by applications to\naccess Google APIs programmatically via OAuth 2.0. A service account uses an\nOAuth 2.0 flow that does not require additional authorization. Instead, it uses\na key file that only your application can access. This guide discusses how to\naccess the Manufacturer Center API with service accounts.\n| **Note:** Applications using service accounts for authentication can only access your own Manufacturer Center account. If you are writing a third-party application that needs access to your clients' Manufacturer Center accounts, see the [Authorizing Requests](/manufacturers/how-tos/authorizing) guide instead.\n\nPrerequisites\n-------------\n\n- A [Manufacturer Center](//manufacturers.google.com/) account.\n\nSteps to using a service account to access the Manufacturer Center API\n----------------------------------------------------------------------\n\n1. Generate service-account credentials or access the public credentials you've\n already generated. You will need to create an OAuth 2.0 Client ID and obtain\n a \\*.json private key file:\n\n 1. Go to the [Google API Console](https://console.cloud.google.com/apis/library).\n\n 2. Select a project in the drop-down menu at the top of the page. If you do\n not have one yet, create one by clicking **Create Project**.\n\n 3. If you have not already enabled the Manufacturer Center API for this\n project, then search for it in the list of Google APIs and enable it.\n\n 4. In the sidebar on the left, select **Credentials**.\n\n 5. To set up a service account, select **Create credentials** , and then\n **Service account key**.\n\n 1. On the next page, select **New service account** from the drop-down\n list.\n\n 2. Name the new service account. This\n also serves as the default username for the service account ID. Remember\n the service account ID for use later.\n\n | **Note:** The choice of role for the service account will not have any effect on what calls can be made to the Manufacturer Center API, as access to Manufacturer Center API methods is determined instead by the role associated with the service account ID in Manufacturer Center. If you are unsure what to pick, just pick Project►Viewer.\n\n 1. Select **JSON** for the key type, then click **Create**.\n\n 2. The **Create** button will change to **Creating...**, and once the key\n generation finishes, it will automatically download the private key as a\n \\*.json file.\n\n | **Important:** Protect the \\*.json key file that allows a service account to access the Google services for which it has been authorized. It is good practice to allow service accounts to only access one Google API each. This is a preventative measure to mitigate the amount of data an attacker can access in the situation that the service account's \\*.json key file is compromised.\n 1. You will be returned to the Credentials page, and you should see the new service account in the list of service account keys for your account.\n2. Add the new service account as a user to your Manufacturer Center account.\n If you are a third party developer, you will need to have your client do\n this step for you.\n\n 1. Go to your [Manufacturer Center account](//manufacturers.google.com/).\n\n 2. Go to the 'Users' list in the settings of your Manufacturer Center\n account.\n\n 3. Click the +User button, and use the service account ID as the email\n address for the new user.\n\n 4. Fill in the form with the [service account ID](#service-account-name),\n and select the desired user role(s). At least one must be chosen, and\n use of the `Accounts` service requires the Admin role.\n\n If you did not take note of the service account ID earlier, go to the\n [Service Accounts](https://console.developers.google.com/iam-admin/serviceaccounts/)\n administration page and select the project you created.\n\n 1. Click on the **Save** button. You will be returned to the list of users,\n and the service account ID should be listed with the chosen user role(s).\n\n 2. Repeat the process for all other service accounts you want to add.\n\n 3. View existing service account users by going to the Users tab. These\n will be users with an email address ending in 'gserviceaccount.com'.\n\n3. Now you can access your Manufacturer Center account using the service\n account either by using the [Google Application Default\n Credentials](/identity/protocols/application-default-credentials) flow or by\n using the [service account flow](/identity/protocols/OAuth2ServiceAccount)\n directly. The Manufacturer Center API [Samples](/manufacturers/libraries)\n show how to use both flows for service account credentials in each supported\n programming language. See the code samples to try out your new service\n account and to learn what changes you will need to use service accounts in\n your own code.\n\nFrequently asked questions\n--------------------------\n\n#### Can I log into the Manufacturer Center web user interface with my service account?\n\nNo, service accounts are not regular Google accounts and cannot access the\nManufacturer Center web user interface.\n\n#### How often do I need to refresh service account access tokens?\n\nAccess tokens expire one hour after they are issued by the Google OAuth 2.0\nAuthorization Server. When an access token expires, the application should use\nthe client library to fetch another access token."]]