Die Zugriffssteuerung auf APIs ist ein wesentlicher Bestandteil der Entwicklung. Unter Umständen möchten Sie beim Testen Ihrer API die neue Bereitstellung aktualisierter Konfigurationen von Cloud Endpoints automatisieren und dazu ein Dienstkonto mit den entsprechenden Berechtigungen verwenden. Standardmäßig kann nur der Projektinhaber den Zugriff auf eine API verwalten. Auf dieser Seite erfahren Sie, wie Sie mit derGoogle Cloud -Konsole oder der Google Cloud CLI Zugriff auf Ihre API gewähren und widerrufen.
In Endpoints werden zum Gewähren und Widerrufen des Zugriffs auf API-Ebene die Rollen des Identity and Access Management verwendet. Sie können einem Nutzer, einem Dienstkonto oder einer Google-Gruppe Zugriff gewähren und entziehen.
Google-Gruppen bieten eine bequeme Möglichkeit, um einer bestimmten Menge von Nutzern Zugriff zu gewähren oder den Zugriff für sie zu widerrufen. Sie können den Zugriff für eine ganze Gruppe auf einmal gewähren oder widerrufen, anstatt dies für einzelne Nutzer oder Dienstkonten separat zu erledigen. Mitglieder lassen sich auch einfach in eine Google-Gruppe einfügen und daraus entfernen, sodass nicht für jedes Mitglied einzeln eine IAM-Rolle gewährt oder widerrufen werden muss.
Zugriff gewähren
Google Cloud console
Rufen Sie in der Google Cloud Console die Seite Endpoints > Dienste für Ihr Projekt auf.
Wenn Sie mehr als eine API haben, klicken Sie auf den Namen der API.
Wenn die Seitenleiste Berechtigungen nicht geöffnet ist, klicken Sie auf addBerechtigungen.
Geben Sie die E-Mail-Adresse des Nutzers, Dienstkontos oder der Google-Gruppe in das Feld Mitglieder hinzufügen ein.
Klicken Sie im Drop-down-Menü Rolle auswählen auf Dienstverwaltung und wählen Sie eine der folgenden Rollen aus:
Dienstnutzer: Diese Rolle enthält die Berechtigungen für ein Nicht-Projektmitglied zum Aufrufen und Aktivieren der API in einem eigenen Projekt. Wenn Sie ein Portal für Ihre API erstellt haben, ermöglicht diese Rolle Ihren API-Nutzern den Zugriff auf das Portal.
Service Controller:Diese Rolle enthält die Berechtigungen zum Ausführen von Aufrufen an die Methoden check und
report in der Service Infrastructure API während der Laufzeit.
Dienstkonfigurationsbearbeiter: Diese Rolle enthält die Berechtigungen, die von Service Management mindestens benötigt werden, um eine Endpoints-Konfiguration für einen vorhandenen Dienst bereitzustellen.
Service Management-Administrator: Diese Rolle enthält die Berechtigungen der Rollen Dienstkonfigurationsbearbeiter, Dienstnutzer und Dienstüberwacher und zusätzlich die erforderlichen Berechtigungen, um mit gcloud oder den unter Zugriff auf Ressourcen erteilen, ändern und entziehen beschriebenen programmgesteuerten Methoden den Zugriff auf diese API zu gewähren.
Informationen zu dieser Rolle finden Sie unter Zugriffssteuerung für die Service Management API. Sie können in der Google Cloud Console zwar andere Rollen auswählen, aber sie sind für die Verwaltung Ihrer API nicht hilfreich.
Klicken Sie auf Hinzufügen, um das Mitglied in die angegebene IAM-Rolle aufzunehmen.
Fügen Sie nach Bedarf weitere Mitglieder hinzu und wählen Sie die gewünschten Rollen aus.
Mit den Service Management-Rollen können Nutzer nicht auf die Seite Endpoints > Dienste in der Google Cloud Console zugreifen. Wenn Sie möchten, dass Nutzer die Seite Endpoints > Dienste öffnen können, müssen Sie ihnen die Rolle Projektbetrachter oder eine höhere Rolle für das Projekt zuweisen. Weitere Informationen finden Sie unter Zugriff auf Ressourcen erteilen, ändern und entziehen.
gcloud
Öffnen Sie Cloud Shell oder ein Terminalfenster, sofern die Google Cloud CLI installiert ist.
Geben Sie den entsprechenden gcloud-Befehl ein:
Wenn Sie einem Nutzer Zugriff gewähren, führen Sie diesen Befehl aus:
Geben Sie als Rolle eine der folgenden IAM-Rollen an:
roles/servicemanagement.configEditor: Diese Rolle enthält die Berechtigungen, die von Service Management mindestens benötigt werden, um eine Endpoints-Konfiguration für einen vorhandenen Dienst bereitzustellen.
roles/servicemanagement.admin: Diese Rolle enthält die Berechtigungen der Rollen roles/servicemanagement.configEditor, roles/servicemanagement.serviceConsumer und roles/servicemanagement.serviceController sowie zusätzlich die erforderlichen Berechtigungen, um mit gcloud oder den unter Zugriff auf Ressourcen erteilen, ändern und entziehen beschriebenen programmgesteuerten Methoden den Zugriff auf diese API zu gewähren.
Mit den Service Management-Rollen können Nutzer nicht auf die Seite Endpoints > Dienste in der Google Cloud Console zugreifen. Wenn Sie möchten, dass Nutzer die Seite Endpoints > Dienste öffnen können, müssen Sie ihnen die Rolle Projektbetrachter oder eine höhere Rolle für das Projekt zuweisen. Weitere Informationen finden Sie unter Zugriff auf Ressourcen erteilen, ändern und entziehen.
Zugriff widerrufen
Wenn Sie den Zugriff auf die API widerrufen möchten, können Sie dem Mitglied die ihm zuvor zugewiesene IAM-Rolle entziehen.
Google Cloud console
Rufen Sie in der Google Cloud Console die Seite Endpoints > Services für Ihr Projekt auf.
Wenn Sie mehr als eine API haben, klicken Sie auf den Namen der API.
Wenn die Seitenleiste Berechtigungen nicht geöffnet ist, klicken Sie auf addBerechtigungen.
Gehen Sie zu dem Mitglied, dessen Zugriffsrechte Sie widerrufen möchten. Sie können entweder auf die entsprechende Rollenkarte klicken, um eine Liste der Mitglieder aufzurufen, oder einen Namen oder eine Rolle in das Feld Mitglieder suchen eingeben.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eThis document details how to manage API access using Google Cloud Endpoints, emphasizing the importance of controlling who can interact with your API.\u003c/p\u003e\n"],["\u003cp\u003eAccess to an API can be granted or revoked for individual users, service accounts, or Google Groups via Identity and Access Management (IAM) roles.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Cloud console and the Google Cloud CLI (\u003ccode\u003egcloud\u003c/code\u003e) are the tools that are provided for managing API access, which includes various Service Management roles to configure specific permission levels.\u003c/p\u003e\n"],["\u003cp\u003eRevoking access involves removing the assigned IAM role from the user, service account, or Google Group, through either the Google Cloud console or the \u003ccode\u003egcloud\u003c/code\u003e command-line tool.\u003c/p\u003e\n"],["\u003cp\u003eUsers may require the "Project Viewer" role, in addition to the Service Management roles, in order to view the "Endpoints > Services" page on the Google Cloud console.\u003c/p\u003e\n"]]],[],null,["# Granting and revoking access to the API\n\n[OpenAPI](/endpoints/docs/openapi/control-api-access \"View this page for the Cloud Endpoints OpenAPI docs\") \\| gRPC\n\n\u003cbr /\u003e\n\nControlling who has access to an API is an integral part of development. For\nexample, as you test your API, you might want to automate redeploying updated\nCloud Endpoints configurations by using a service account that has the\npermission to do so. By default, only the project owner can manage access to an\nAPI. This page shows you how to grant and revoke access to your API by using the\nGoogle Cloud console or the Google Cloud CLI.\n\nEndpoints uses\n[Identity and Access Management](/iam/docs/overview)\nroles to grant and revoke access at the API level. You can grant and revoke\naccess to a user, service account, or to a\n[Google Group](https://support.google.com/groups/answer/2464926).\n\nGoogle Groups are a convenient way to grant or revoke access to a collection of\nusers. You can grant or revoke access for a whole group at once, instead of\ngranting or revoking access one at a time for individual users or service\naccounts. You can also easily add members to and remove members from a\nGoogle Group instead of granting or revoking the IAM role for\neach member.\n\nGranting access\n---------------\n\n### Google Cloud console\n\n1. In the Google Cloud console, go to the **Endpoints \\\u003e Services** page for your project.\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n2. If you have more than one API, click the name of the API.\n3. If the **Permissions** side panel isn't open, click **addPermissions**.\n4. In the **Add members** box, enter the email address of a user, service account, or Google Group.\n5. In the **Select a role** drop-down, click **Service Management** , and select one of the following roles:\n - **Service Consumer:** This role contains the permissions for a non-project member to view and enable the API in their own project. If you have created a [portal](/endpoints/docs/openapi/dev-portal-overview) for your API, this role lets your API users access the portal.\n - **Service Controller:** This role contains the permissions to make calls to the `check` and `\n report` methods in the [Service Infrastructure](/service-infrastructure/docs/checking-status) API during runtime.\n - **Service Config Editor:** This role contains the minimum permissions that Service Management requires to deploy an Endpoints configuration to an existing service.\n - **Service Management Administrator:** This role contains the permissions in the Service Config Editor, Service Consumer, and Service Controller roles, plus the permissions required to grant access to this API by using `gcloud` or the programmatic methods described in [Granting, changing, and revoking access to resources](/iam/docs/granting-changing-revoking-access).\n\n\n See the [Service Management API access control](/service-infrastructure/docs/service-management/access-control#roles)\n topic for information about this role. Although the Google Cloud console allows you to select other roles,\n those roles aren't useful for managing your API.\n6. To add the member to the specified IAM role, click **Add**.\n7. Repeat adding members and selecting the role, as needed.\n8. The Service Management roles don't allow users to access the **Endpoints** \\\u003e **Services** page in the Google Cloud console. If you want users to be able access the **Endpoints** \\\u003e **Services** page, you must grant them the **Project Viewer** role or a higher role on the project. See [Granting, changing,\n and revoking access to resources](/iam/docs/granting-changing-revoking-access) for details.\n\n### gcloud\n\n1. Open Cloud Shell, or if you have the Google Cloud CLI installed, open a terminal window.\n2. Enter the applicable `gcloud` command:\n - If you are granting access to a user, run the following: \n\n ```transact-sql\n gcloud endpoints services add-iam-policy-binding [SERVICE-NAME] \\\n --member='user:[EMAIL-ADDRESS]' \\\n --role='[ROLE]'\n ```\n\n For the role, specify one of the following IAM roles:\n - `roles/servicemanagement.configEditor`: This role contains the minimum permissions that Service Management requires to deploy an Endpoints configuration to an existing service.\n - `roles/servicemanagement.admin`: This role contains the permissions in `roles/servicemanagement.configEditor`, `roles/servicemanagement.serviceConsumer`, and `roles/servicemanagement.serviceController`, plus the permissions required to grant access to this API by using `gcloud` or the programmatic methods described in [Granting,\n changing, and revoking access to resources](/iam/docs/granting-changing-revoking-access).\n\n \u003cbr /\u003e\n\n For example: \n\n ```transact-sql\n gcloud endpoints services add-iam-policy-binding example-service-name \\\n --member='user:example-user@gmail.com' \\\n --role='roles/servicemanagement.admin'\n ```\n\n \u003cbr /\u003e\n\n - If you are granting access to a service account, run the following: \n\n ```transact-sql\n gcloud endpoints services add-iam-policy-binding [SERVICE-NAME] \\\n --member='serviceAccount:[EMAIL-ADDRESS]' \\\n --role='[ROLE]'\n ```\n\n For example: \n\n ```transact-sql\n gcloud endpoints services add-iam-policy-binding example-service-name \\\n --member='serviceAccount:example-service-account@example-project.iam.gserviceaccount.com' \\\n --role='roles/servicemanagement.configEditor'\n ```\n\n \u003cbr /\u003e\n\n - If you are granting access to a Google Group, run the following: \n\n ```transact-sql\n gcloud endpoints services add-iam-policy-binding [SERVICE-NAME] \\\n --member='group:[GROUP-NAME]@googlegroups.com' \\\n --role='[ROLE]'\n ```\n\n For example: \n\n ```transact-sql\n gcloud endpoints services add-iam-policy-binding example-service-name \\\n --member='group:example-group@googlegroups.com' \\\n --role='roles/servicemanagement.configEditor'\n ```\n\n \u003cbr /\u003e\n\n3. The Service Management roles don't allow users to access the **Endpoints** \\\u003e **Services** page in the Google Cloud console. If you want users to be able access the **Endpoints** \\\u003e **Services** page, you must grant them the **Project Viewer** role or a higher role on the project. See [Granting, changing,\n and revoking access to resources](/iam/docs/granting-changing-revoking-access) for details.\n\nRevoking access\n---------------\n\nTo revoke access to your API, remove the IAM role from the member\nwho previously had the role. \n\n### Google Cloud console\n\n1. In the Google Cloud console, go to the **Endpoints** \\\u003e **Services** page for your project.\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n2. If you have more than one API, click the name of the API.\n3. If the **Permissions** side panel isn't open, click **addPermissions**.\n4. Locate the member for whom you want to revoke access. You can either click the applicable **Role** card to see a list of members, or you can enter a name or role in the **Search members** box.\n5. Click **Delete** delete.\n6. If you also want to revoke a user's access to your Google Cloud project, see [Granting,\n changing, and revoking access to resources](/iam/docs/granting-changing-revoking-access) for details.\n\n### gcloud\n\n1. Open Cloud Shell, or, if you have the gcloud CLI installed, open a terminal window.\n2. Enter the applicable `gcloud` command:\n - If you are revoking access for a user, run the following: \n\n ```text\n gcloud endpoints services remove-iam-policy-binding [SERVICE-NAME] \\\n --member='user:[EMAIL-ADDRESS]' \\\n --role='[ROLE-NAME]'\n ```\n\n For example: \n\n ```transact-sql\n gcloud endpoints services remove-iam-policy-binding example-service-name \\\n --member='user:example-user@gmail.com' \\\n --role='roles/editor'\n ```\n - If you are revoking access for a service account, run the following: \n\n ```text\n gcloud endpoints services remove-iam-policy-binding [SERVICE-NAME] \\\n --member='serviceAccount:[EMAIL-ADDRESS]' \\\n --role='[ROLE-NAME]'\n ```\n\n For example: \n\n ```transact-sql\n gcloud endpoints services remove-iam-policy-binding example-service-name \\\n --member='serviceAccount:example-service-account@example-project.iam.gserviceaccount.com' \\\n --role='roles/servicemanagement.configEditor'\n ```\n - If you are revoking access for a Google Group, run the following: \n\n ```transact-sql\n gcloud endpoints services remove-iam-policy-binding [SERVICE-NAME] \\\n --member='group:[GROUP-NAME]@googlegroups.com' \\\n --role='[ROLE-NAME]'\n ```\n\n For example: \n\n ```transact-sql\n gcloud endpoints services remove-iam-policy-binding example-service-name \\\n --member='group:example-group@googlegroups.com' \\\n --role='roles/viewer'\n ```\n3. If you also want to revoke a user's access to your Google Cloud project, see [Granting,\n changing, and revoking access to resources](/iam/docs/granting-changing-revoking-access) for details.\n\nWhat's next\n-----------\n\nLearn about:\n\n- [Creating a service account](/iam/docs/creating-managing-service-accounts#creating_a_service_account)\n- [`gcloud` commands](/sdk/gcloud/reference) referenced on this page."]]