Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Les clés API sont associées au projet Google Cloud dans lequel elles ont été créées. Si votre API nécessite une clé API, vous devez donner aux utilisateurs de votre API une clé du projet dans lequel vous avez créé le service Cloud Endpoints, ou bien autoriser les utilisateurs à activer votre API dans leur propre Google CloudProjet et créer une clé API. Cette page vous montre comment accorder l'autorisation dont les utilisateurs ont besoin pour activer votre API.
Accorder l'accès
Cloud Endpoints utilise le rôle Client du service de Identity and Access Management (IAM) pour autoriser une personne non membre de votre projetGoogle Cloud à activer votre API dans son propre projet Google Cloud. Cette section explique comment accorder un accès à l'aide de la consoleGoogle Cloud ou de Google Cloud CLI.
ConsoleGoogle Cloud
Dans la console Google Cloud , accédez à la page Endpoints > Services de votre projet.
Si vous avez plusieurs API, cliquez sur le nom de l'API à laquelle vous souhaitez accorder l'accès.
Si le panneau latéral Autorisations n'est pas ouvert, cliquez sur Afficher le panneau des autorisations.
Dans le champ Ajouter un compte principal, saisissez l'adresse e-mail de la personne ou du groupe Google auquel vous souhaitez accorder l'accès.
Dans le menu déroulant Sélectionner un rôle, sélectionnez Service Management > Client du service.
Cliquez sur Enregistrer.
Répétez les étapes d'ajout de membres et de sélection du rôle autant que nécessaire.
Contactez les utilisateurs ou les groupes que vous avez ajoutés pour leur indiquer qu'ils peuvent activer l'API dans leurs Google Cloud projets. Pour en savoir plus sur l'activation d'un service dans les API et services, consultez la page Activer une API dans votre projet Google Cloud.
gcloud
Ouvrez Cloud Shell ou, si vous avez installé la Google Cloud CLI, ouvrez une fenêtre de terminal.
Si vous accordez l'accès à un utilisateur individuel, utilisez :
Contactez les utilisateurs ou les groupes que vous avez ajoutés pour leur indiquer qu'ils peuvent activer l'API dans leurs Google Cloud projets. Pour en savoir plus sur l'activation d'un service dans les API et services, consultez la page Activer une API dans votre projet Google Cloud.
Révoquer l'accès
Pour révoquer l'accès à votre API, supprimez le rôle IAM Client du service précédemment attribué à un utilisateur ou à un groupe. Une fois l'accès d'une personne révoqué, celle-ci ne pourra plus activer votre API.
Cette section explique comment révoquer l'accès à l'aide de la console Google Cloud ou de Google Cloud CLI.
ConsoleGoogle Cloud
Dans la console Google Cloud , accédez à la page Endpoints > Services de votre Google Cloud projet.
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/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\u003cp\u003eAPI access is granted by assigning the \u003cstrong\u003eService Consumer\u003c/strong\u003e role from Identity and Access Management (IAM) to users or Google Groups, allowing them to enable the API in their own Google Cloud projects.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Cloud console or the gcloud command-line tool can be used to add a user or group to the \u003cstrong\u003eService Consumer\u003c/strong\u003e role, which then allows them to access an API.\u003c/p\u003e\n"],["\u003cp\u003eAccess to an API can be revoked by removing the \u003cstrong\u003eService Consumer\u003c/strong\u003e role from a user or group using either the Google Cloud console or gcloud commands, but it does not stop users who have already enabled the API from calling it.\u003c/p\u003e\n"],["\u003cp\u003eOnce access is granted, users should be informed and directed on how to enable the API in their Google Cloud projects.\u003c/p\u003e\n"],["\u003cp\u003eAPI Keys are linked to a specific Google cloud project, where the API was created, and can be shared for API access, or users can create their own in their respective projects.\u003c/p\u003e\n"]]],[],null,["# Controlling who can enable your API\n\n\u003cbr /\u003e\n\nAPI keys are associated with the Google Cloud project in which\nthey have been created. If your API requires an API key, you either have to give\nyour API users a key from the project that you created the Cloud Endpoints\nservice in, or you can let users enable your API in their own Google Cloud\nproject and create an API key. This page shows you how to grant the permission\nthat users need to enable your API.\n\nGranting access\n---------------\n\nEndpoints uses the\n[Identity and Access Management (IAM)](/iam/docs)\n**Service Consumer** role to allow someone who isn't a member of your\nGoogle Cloud project to enable your API in their own Google Cloud\nproject. This section shows you how to grant access using the\nGoogle Cloud console or the Google Cloud CLI. \n\n### Google Cloud console\n\n1. In the Google Cloud console, go to the **Endpoints** \\\u003e **Services** page for your project.\n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e\n\n2. If you have more than one API, click the name of the API that you want to grant access to.\n3. If the **Permissions** side panel isn't open, click **Show Permissions Panel**.\n4. In the **Add Principal** field, enter the email address of the person or [Google Group](https://support.google.com/groups/answer/2464926) that you want to grant access to.\n5. In the **Select a role** drop-down menu, select **Service Management** \\\u003e **Service Consumer**.\n6. Click **Save**.\n7. Repeat adding members and selecting the role, as needed.\n8. Contact the users or groups that you added and let them know they can enable the API in their Google Cloud projects. See [Enable an API in your Google Cloud\n project](/endpoints/docs/frameworks/enable-api) for information on how to enable a service in APIs \\& services.\n\n### gcloud\n\n1. Open Cloud Shell, or if you have the Google Cloud CLI installed, open a terminal window.\n - If you are granting access to an individual user:\n\n - If you are granting access to a Google Group:\n\n2. Contact the users or groups that you added and let them know they can enable the API in their Google Cloud projects. See [Enable an API in your Google Cloud\n project](/endpoints/docs/frameworks/enable-api) for information on how to enable a service in APIs \\& services.\n\nRevoking access\n---------------\n\nYou revoke access to your API by removing the **Service Consumer** role from a\nuser or group that previously had the role. After you revoke someone's access,\nthey won't be able to enable your API.\n| **Note:** If someone has already enabled your API, revoking access doesn't prevent them from calling your API. Although there is no easy way to to prevent these calls, you can add logic to your code that disallows calls from a specific caller's API key.\n\nThis section shows you how to revoke access using the Google Cloud console or\nthe Google Cloud CLI. \n\n### Google Cloud console\n\n1. In the Google Cloud console, go to the **Endpoints** \\\u003e **Services** page for your Google Cloud project.\n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e\n\n2. If you have more than one API, click the name of the API that you want to revoke access to.\n3. If the **Permissions** side panel isn't open, click **addPermissions**.\n4. Click the **Role** card that the member belongs to.\n5. Click **Delete** delete.\n\n### gcloud\n\n- If you are revoking access for an individual user:\n\n- If you are revoking access for a Google Group:\n\nWhat's next\n-----------\n\n- Tell users how to [enable your API in their Google Cloud project](/endpoints/docs/frameworks/enable-api).\n\n\u003c!-- --\u003e\n\n- Learn more about sharing APIs protected by API keys.\n\n - [Java: Sharing APIs protected by API key](/endpoints/docs/frameworks/java/restricting-api-access-with-api-keys-frameworks#sharing_apis_protected_by_api_key)\n - [Python: Sharing APIs protected by API key](/endpoints/docs/frameworks/java/restricting-api-access-with-api-keys-frameworks#sharing_apis_protected_by_api_key)\n\n\u003c!-- --\u003e\n\n- Create a [Cloud Endpoints Portal](/endpoints/docs/frameworks/dev-portal-overview) for your users."]]