Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Il controllo di chi ha accesso a un'API è parte integrante dello sviluppo. Ad esempio, durante il test dell'API, potresti voler automatizzare il redeployment delle configurazioni di Cloud Endpoints aggiornate utilizzando un account di servizio che abbia l'autorizzazione per farlo. Per impostazione predefinita, solo il proprietario del progetto può gestire l'accesso a un'API. Questa pagina mostra come concedere e revocare l'accesso all'API utilizzando la console o la CLI Google Cloud.Google Cloud
Gli endpoint utilizzano i ruoli di Identity and Access Management per concedere e revocare l'accesso a livello di API. Puoi concedere e revocare
l'accesso a un utente, a un account di servizio o a un
gruppo Google.
Google Gruppi è un modo pratico per concedere o revocare l'accesso a una raccolta di
utenti. Puoi concedere o revocare l'accesso a un intero gruppo contemporaneamente, anziché concederlo o revocarlo uno alla volta per singoli utenti o account di servizio. Puoi anche aggiungere e rimuovere facilmente membri da un gruppo Google anziché concedere o revocare il ruolo IAM per ogni membro.
Concedere l'accesso
Google Cloud console
Nella Google Cloud console, vai alla pagina Endpoints > Servizi per il tuo progetto.
Se il riquadro laterale Autorizzazioni non è aperto, fai clic su addAutorizzazioni.
Nella casella Aggiungi membri, inserisci l'indirizzo email di un utente, di un account di servizio o di un gruppo Google.
Nel menu a discesa Seleziona un ruolo, fai clic su Gestione servizi e
seleziona uno dei seguenti ruoli:
Consumer servizi:questo ruolo contiene le autorizzazioni per consentire a un utente non appartenente al progetto di visualizzare e attivare l'API nel proprio progetto. Se hai creato un
portale per la tua
API, questo ruolo consente agli utenti dell'API di accedere al portale.
Service Controller: questo ruolo contiene le autorizzazioni per effettuare chiamate ai metodi check e
report nell'API Service Infrastructure durante il runtime.
Editor di Service Config:questo ruolo contiene le autorizzazioni minime necessarie per eseguire il deployment di una configurazione di Endpoints in un servizio esistente.
Amministratore di gestione dei servizi:questo ruolo contiene le autorizzazioni dei ruoli Editor di configurazione del servizio, Consumatore di servizi e Controllore di servizi, oltre alle autorizzazioni necessarie per concedere l'accesso a questa API utilizzando gcloud o i metodi programmatici descritti in
Concessione, modifica e revoca dell'accesso alle risorse.
Per informazioni su questo ruolo, consulta l'argomento Controllo dell'accesso all'API Service Management. Sebbene la Google Cloud console ti consenta di selezionare altri ruoli,
questi ruoli non sono utili per la gestione dell'API.
Per aggiungere il membro al ruolo IAM specificato, fai clic su Aggiungi.
Ripeti l'aggiunta di membri e la selezione del ruolo, se necessario.
I ruoli di gestione dei servizi non consentono agli utenti di accedere alla pagina Endpoint >
Servizi nella Google Cloud console. Se vuoi che gli utenti possano accedere alla pagina Endpoint > Servizi, devi concedere loro il ruolo Visualizzatore progetto o un ruolo superiore nel progetto. Per maggiori dettagli, consulta la sezione Concessione, modifica e revoca dell'accesso alle risorse.
gcloud
Apri Cloud Shell o, se hai installato Google Cloud CLI, apri una
finestra del terminale.
Inserisci il comando gcloud applicabile:
Se stai concedendo l'accesso a un utente, esegui quanto segue:
Per il ruolo, specifica uno dei seguenti ruoli IAM:
roles/servicemanagement.configEditor: questo ruolo contiene le autorizzazioni minime richieste da Service Management per eseguire il deployment di una configurazione di Endpoints in un servizio esistente.
roles/servicemanagement.admin: questo ruolo contiene le autorizzazioni in roles/servicemanagement.configEditor, roles/servicemanagement.serviceConsumer e roles/servicemanagement.serviceController, oltre alle autorizzazioni necessarie per concedere l'accesso a questa API utilizzando gcloud o i metodi programmatici descritti in Concessione, modifica e revoca dell'accesso alle risorse.
I ruoli di gestione dei servizi non consentono agli utenti di accedere alla pagina Endpoint > Servizi nella Google Cloud console. Se
vuoi che gli utenti possano accedere alla pagina Endpoint > Servizi, devi concedergli il ruolo
Visualizzatore progetto o un ruolo superiore nel progetto. Per maggiori dettagli, consulta la sezione Concessione, modifica e revoca dell'accesso alle risorse.
Revocare l'accesso
Per revocare l'accesso all'API, rimuovi il ruolo IAM dal membro
che lo deteneva in precedenza.
Google Cloud console
Nella Google Cloud console, vai alla pagina Endpoints > Servizi per il tuo progetto.
Se il riquadro laterale Autorizzazioni non è aperto, fai clic su addAutorizzazioni.
Individua il membro per cui vuoi revocare l'accesso. Puoi fare clic sulla scheda Ruolo applicabile per visualizzare un elenco di membri oppure inserire un nome o un ruolo nella casella Cerca membri.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eAPI access can be managed by granting or revoking Identity and Access Management (IAM) roles to users, service accounts, or Google Groups, controlling who can interact with the API.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Groups provide a streamlined way to manage access for multiple users simultaneously, simplifying the process of adding or removing permissions for a collection of individuals.\u003c/p\u003e\n"],["\u003cp\u003eAccess can be granted or revoked via the Google Cloud console by navigating to the Endpoints Services page, or by using the \u003ccode\u003egcloud\u003c/code\u003e command-line tool with specific commands for users, service accounts, and groups.\u003c/p\u003e\n"],["\u003cp\u003eService Management roles control different levels of access, such as Service Consumer, Service Controller, Service Config Editor, and Service Management Administrator, each providing a unique level of control.\u003c/p\u003e\n"],["\u003cp\u003eGranting Service Management roles does not give users access to the \u003cstrong\u003eEndpoints > Services\u003c/strong\u003e page in the Google Cloud Console, to access the page users must be granted the \u003cstrong\u003eProject Viewer\u003c/strong\u003e role or a higher role.\u003c/p\u003e\n"]]],[],null,["# Granting and revoking access to the API\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."]]