Controlar quién tiene acceso a una API es una parte integral del desarrollo. Por ejemplo, a medida que pruebes tu API, es posible que desees automatizar la reasignación de configuraciones actualizadas de Cloud Endpoints mediante una cuenta de servicio que tenga permiso para hacerlo. De forma predeterminada, solo el propietario del proyecto puede administrar el acceso a una API. En esta página, se muestra cómo otorgar y revocar el acceso a la API mediante la consola deGoogle Cloud o Google Cloud CLI.
Endpoints usa las funciones de la administración de identidades y accesos para otorgar y revocar el acceso al nivel de la API. Puedes otorgar y revocar el acceso a un usuario, una cuenta de servicio o un Grupo de Google.
Los Grupos de Google ofrecen una forma práctica de otorgar o revocar el acceso a una colección de usuarios. Puedes otorgar y revocar el acceso a todo un grupo de una sola vez, en lugar de otorgar y revocar el acceso a usuarios individuales o cuentas de servicio de a una a la vez. También puedes agregar miembros a un Grupo de Google, o quitarlos, con facilidad, en lugar de otorgar o revocar la función de IAM a cada miembro.
Otorga acceso
Google Cloud console
En la Google Cloud consola, ve a la página Endpoints > Services de tu proyecto.
Si tienes más de una API, haz clic en el nombre de la API.
Si el panel lateral Permisos no está abierto, haz clic en addPermisos.
En el cuadro Agregar miembros, ingresa la dirección de correo electrónico de un usuario, cuenta de servicio o Grupo de Google.
En el menú desplegable Seleccionar una función, haz clic en Service Management y selecciona una de las funciones siguientes:
Consumidor del servicio: Esta función contiene los permisos para que un miembro ajeno al proyecto vea y habilite la API en su propio proyecto. Si creaste un portal para tu API, esta función les permite a los usuarios de la API acceder al portal.
Controlador de servicio: Esta función contiene los permisos para realizar llamadas a los métodos check y
report en la API de Service Infrastructure durante el tiempo de ejecución.
Editor de Service Management: esta función contiene los permisos mínimos que requiere Service Management para implementar una configuración de Endpoints en un servicio existente.
Administrador de Service Management: Esta función contiene los permisos de las funciones Editor de configuración de servicios, Consumidor de servicios y Controlador de servicios, además de los permisos necesarios para otorgar acceso a esta API mediante gcloud o los métodos programáticos que se describen en Cómo otorgar, cambiar y revocar el acceso a los recursos.
Consulta el tema Control de acceso a la API de Administración de servicios para obtener información sobre esta función. Aunque la consola de Google Cloud te permite seleccionar otros roles, estos no son útiles para administrar tu API.
Para agregar el miembro a la función de Cloud IAM especificada, haz clic en Agregar.
Continúa agregando miembros y seleccionando funciones según sea necesario.
Los roles de Service Management no permiten que los usuarios accedan a la página Endpoints > Services en la consola de Google Cloud . Si quieres que los usuarios puedan acceder a la página Endpoints > Services, debes otorgarles la función Visualizador de proyecto o una función superior en el proyecto. Consulta Cómo otorgar, cambiar y revocar el acceso a los recursos para obtener más detalles.
gcloud
Abre Cloud Shell o, si tienes Google Cloud CLI instalado, abre una ventana de la terminal.
Ingresa el comando gcloud aplicable:
Ejecuta el siguiente código para otorgar el acceso a un usuario:
Para la función, especifica una de las siguientes funciones de Cloud IAM:
roles/servicemanagement.configEditor: Esta función contiene los permisos mínimos que requiere Service Management para implementar una configuración de Endpoints en un servicio existente.
roles/servicemanagement.admin: Esta función contiene los permisos de roles/servicemanagement.configEditor, roles/servicemanagement.serviceConsumer y roles/servicemanagement.serviceController, además de los permisos necesarios para otorgar acceso a esta API mediante gcloud o los métodos programáticos que se describen en la sección Cómo otorgar, cambiar y revocar el acceso a los recursos.
Los roles de Service Management no permiten que los usuarios accedan a la página Endpoints > Services en la consola de Google Cloud . Si quieres que los usuarios puedan acceder a la página Endpoints > Services, debes otorgarles la función Visualizador de proyecto o una función superior en el proyecto. Consulta Cómo otorgar, cambiar y revocar el acceso a los recursos para obtener más detalles.
Revoca acceso
Para revocar el acceso a tu API, quítale la función de IAM al miembro que la tenía antes.
Google Cloud console
En la Google Cloud consola, ve a la página Endpoints > Services de tu proyecto.
Si tienes más de una API, haz clic en el nombre de la API.
Si el panel lateral Permisos no está abierto, haz clic en addPermisos.
Localiza al miembro al que quieras revocarle el acceso. Puedes hacer clic en la tarjeta aplicable Función para ver una lista de miembros o puedes ingresar un nombre o una función en el cuadro Buscar miembros.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eThis document details how to manage API access using Google Cloud's Identity and Access Management (IAM) roles for users, service accounts, or Google Groups.\u003c/p\u003e\n"],["\u003cp\u003eAPI access can be granted through the Google Cloud console by navigating to the Endpoints Services page and selecting from the Service Management roles available, such as Service Consumer, Service Controller, Service Config Editor, and Service Management Administrator.\u003c/p\u003e\n"],["\u003cp\u003eAccess can also be granted or revoked using the \u003ccode\u003egcloud\u003c/code\u003e CLI by employing the \u003ccode\u003egcloud endpoints services add-iam-policy-binding\u003c/code\u003e and \u003ccode\u003egcloud endpoints services remove-iam-policy-binding\u003c/code\u003e commands, respectively.\u003c/p\u003e\n"],["\u003cp\u003eGranting Service Management roles alone does not allow users to access the Endpoints > Services page; for this, users need the Project Viewer role or higher.\u003c/p\u003e\n"],["\u003cp\u003eRevoking API access involves removing the assigned IAM role from the member either through the Google Cloud console or by utilizing \u003ccode\u003egcloud\u003c/code\u003e CLI commands, effectively removing their permissions.\u003c/p\u003e\n"]]],[],null,["# Granting and revoking access to the API\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/control-api-access \"View this page for the Cloud Endpoints gRPC docs\")\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."]]