Crea clientes de OAuth para IAP de manera programática
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se describe cómo crear clientes de OAuth de manera programática a fin de usarlos con IAP, lo que te permite configurar IAP de manera programática de principio a fin para aplicaciones internas.
Limitaciones conocidas
Existen algunas limitaciones para los clientes de OAuth creados de manera programática con esta API:
Los clientes de OAuth creados por la API solo se pueden modificar mediante la API. No puedes modificar un cliente de OAuth a través de la consola de Google Cloud si se creó con la API.
Los clientes de OAuth creados por la API están bloqueados solo para el uso de IAP y, por lo tanto, la API no permite ninguna actualización del URI de redireccionamiento ni de otros atributos.
La API no opera en los clientes de OAuth que se crearon con la consola de Google Cloud .
Solo se permiten 500 clientes de OAuth por proyecto cuando se utiliza la API.
Las marcas de la pantalla de consentimiento de OAuth creadas por las API tienen limitaciones específicas. Consulta la sección a continuación para obtener más información.
Comprende las marcas y el estado de la marca
La pantalla de consentimiento de OAuth, que contiene información de marca para los usuarios, se conoce como una marca. Las marcas pueden estar limitadas a usuarios internos o a usuarios públicos. Una marca interna hace que el flujo de OAuth sea accesible para alguien que pertenece a la misma organización del lugar de trabajo de Google que el proyecto. Una marca pública hace que el flujo de OAuth esté disponible para cualquier persona en Internet.
Las marcas se pueden crear de forma manual o programática a través de una API. Las marcas creadas con API se configuran automáticamente con diferentes configuraciones:
Están configuradas como internas y las debes configurar de forma manual como públicas si lo deseas
Están configuradas en un estado “no revisada” y se debe activar una revisión de marca
Para configurar manualmente una marca interna como pública, haz lo siguiente:
En la página Pantalla de consentimiento de OAuth, ten en cuenta que el Tipo de usuario se establece automáticamente en Interno. Para configurarlo en Público, haz clic en Editar aplicación. Hay más opciones de configuración disponibles.
En Tipo de aplicación, haz clic en Público.
Para activar una revisión de marca para una marca no revisada creada por API, sigue estos pasos:
En la página Pantalla de consentimiento de OAuth, ingresa la información requerida y, luego, haz clic en Enviar para verificación.
El proceso de verificación puede demorar varias semanas. Recibirás actualizaciones por correo electrónico a medida que progrese.
Más información sobre la verificación. Mientras el proceso de verificación está en curso, puedes usar la aplicación dentro de tu organización de Google Workspace.
Obtén más información sobre cómo se comportará tu aplicación antes de que se verifique.
Antes de comenzar
Antes de poder crear un cliente, primero asegúrate de que la persona que llama tenga otorgados los siguientes permisos:
clientauthconfig.brands.list
clientauthconfig.brands.create
clientauthconfig.brands.get
clientauthconfig.clients.create
clientauthconfig.clients.listWithSecrets (solo es obligatorio para enumerar clientes OAuth con secreto).
clientauthconfig.clients.getWithSecret
clientauthconfig.clients.delete
clientauthconfig.clients.update
Estos permisos se incluyen en las funciones básicas, Editor (roles/editor) y el Propietario (roles/owner), sin embargo, te recomendamos que crees una función personalizada que contenga estos permisos y otorgarlos a la persona que llama.
Configura OAuth para IAP
En los siguientes pasos. se describe cómo configurar la pantalla de consentimiento y crear un cliente de OAuth para IAP.
Configura la pantalla de consentimiento
Para verificar si ya tienes una marca existente, usa el comando list. Solo puedes tener una marca por proyecto.
gcloudiapoauth-brandslist
El siguiente es un ejemplo de respuesta de gcloud, si la marca existe:
Los campos anteriores son obligatorios cuando se llama a esta API:
supportEmail: Es el correo electrónico de asistencia que se muestra en la pantalla de consentimiento de OAuth.
Esta dirección de correo electrónico puede ser la dirección de un usuario o un alias de Grupos de Google.
Si bien las cuentas de servicio también tienen una dirección de correo electrónico, no son direcciones de correo electrónico válidas reales y no se pueden usar cuando se crea una marca. Sin embargo, una cuenta de servicio puede ser propietaria de un Grupo de Google. Crea un Grupo de Google nuevo o configura un grupo existente y configura la cuenta de servicio deseada como propietaria del grupo.
applicationTitle: Es el nombre de la aplicación que se muestra en la pantalla de consentimiento de OAuth.
Usa el ID de cliente (client_id en el ejemplo anterior) y secret para habilitar IAP. Consulta los siguientes temas para obtener más información sobre cómo habilitar IAP con las credenciales que acabas de crear:
[[["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 guide outlines how to programmatically create OAuth clients for Identity-Aware Proxy (IAP) to enable end-to-end setup for internal applications.\u003c/p\u003e\n"],["\u003cp\u003eOAuth clients created via the API are specifically for IAP usage, cannot be modified through the Google Cloud console, and have limited attributes, such as redirect URIs that can not be updated.\u003c/p\u003e\n"],["\u003cp\u003eAPI-created brands for OAuth consent screens are initially set to internal and "unreviewed," requiring manual adjustment to public and submission for a brand review, which will halt the creation of new clients when changed.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating clients, ensure the caller has the required permissions like \u003ccode\u003eclientauthconfig.brands.list\u003c/code\u003e and \u003ccode\u003eclientauthconfig.clients.create\u003c/code\u003e, and that you have a Google Group setup with a valid service account.\u003c/p\u003e\n"],["\u003cp\u003eThe API allows only 500 OAuth clients to be created per project.\u003c/p\u003e\n"]]],[],null,["# Programmatically creating OAuth clients for IAP\n\nThis page describes how to programmatically create OAuth clients for use with\nIAP, enabling you to set up IAP\nprogrammatically end-to-end for internal applications.\n\nKnown limitations\n-----------------\n\nThere are a few limitations for OAuth clients created programmatically\nusing this API:\n\n- OAuth clients created by the API can only be modified by using the API. You cannot modify an OAuth client via the Google Cloud console if it was created by using the API.\n- The OAuth clients created by the API are locked for IAP usage only, and therefore the API does not allow any updates to the redirect URI or other attributes.\n- The API does not operate on the OAuth clients that were created using the Google Cloud console.\n- Only 500 OAuth clients are allowed per project when using the API.\n- API-created OAuth consent screen brands have specific limitations. See the [section below](#branding) for more information.\n\nUnderstanding brands and branding state\n---------------------------------------\n\nThe [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent),\nwhich contains branding information for users, is known as a **brand**. Brands\ncan be limited to internal users or public users. An internal brand makes the\nOAuth flow accessible to someone who belongs to the same Google Workspace\norganization as the project. A public brand makes the OAuth flow available to\nanyone on the internet.\n\nBrands can be created manually or programmatically via an API. API-created\nbrands are automatically configured with different settings:\n\n- They're set to internal and must be manually set to public if desired\n- They're set to an \"unreviewed\" state and a brand review must be triggered\n\nTo manually set an internal brand to public:\n\n1. Open the [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent).\n2. Select your desired project from the drop-down menu.\n3. On the **OAuth consent screen** page, note that the **User Type** is automatically set to **Internal** . To set it to **Public** , click **Edit App**. More configuration options become available.\n4. Under **Application type** , click **Public**.\n\n| **Note:** When an API-created internal brand is set to public, the [`identityAwareProxyClients.create()`](/iap/docs/reference/rest/v1/projects.brands.identityAwareProxyClients/create) API will stop working, as it requires the brand to be set to internal. Therefore, you cannot create new OAuth clients via the API after an internal brand is made public.\n\nTo trigger a brand review for an unreviewed API-created brand:\n\n1. Open the [OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent).\n2. Select your desired project from the drop-down menu.\n3. On the **OAuth consent screen** page, enter any required information, and then click **Submit for verification**.\n\nThe verification process may take up to several weeks, and you will receive\nemail updates as it progresses.\n[Learn more](https://support.google.com/cloud/answer/9110914?hl=en) about\nverification. While the verification process is ongoing, you can still use the\napplication within your Google Workspace organization.\n[Learn more](https://support.google.com/cloud/answer/7454865?hl=en_US) about how\nyour application will behave before it's verified.\n\nBefore you begin\n----------------\n\nBefore you can create a client, first ensure that the caller has been granted\nthe following permissions:\n\n- `clientauthconfig.brands.list`\n- `clientauthconfig.brands.create`\n- `clientauthconfig.brands.get`\n- `clientauthconfig.clients.create`\n- `clientauthconfig.clients.listWithSecrets` (Only required for listing OAuth clients with secret.)\n- `clientauthconfig.clients.getWithSecret`\n- `clientauthconfig.clients.delete`\n- `clientauthconfig.clients.update`\n\nThese permissions are included in the Editor (`roles/editor`) and Owner\n(`roles/owner`) [basic roles](/iam/docs/understanding-roles#basic),\nhowever we recommend that you create a\n[custom role](/iam/docs/understanding-roles#custom_roles) that contains these\npermissions and grant it to the caller instead.\n\nSet up OAuth for IAP\n--------------------\n\nThe following steps describe how to configure the consent screen and create and\noauth client for IAP.\n\n### Configuring consent screen\n\n1. Check if you already have an existing brand by using the\n [list](/sdk/gcloud/reference/iap/oauth-brands/list) command. You may\n only have one brand per project.\n\n ```bash\n gcloud iap oauth-brands list\n ```\n\n The following is an example gcloud response, if the brand exists: \n\n name: projects/[PROJECT_NUMBER]/brands/[BRAND_ID]\n applicationTitle: [APPLICATION_TITLE]\n supportEmail: [SUPPORT_EMAIL]\n orgInternalOnly: true\n\n | **Note:** If a brand already exists for a project and has been configured for external users (`orgInternalOnly: false`), but you want to restrict it to internal users, you must make that change manually from the [OAuth consent screen](https://console.cloud.google.com/auth/audience) in order to create OAuth clients with this API.\n2. If no brand exists, use the\n [create](/sdk/gcloud/reference/iap/oauth-brands/create) command:\n\n ```bash\n gcloud iap oauth-brands create --application_title=APPLICATION_TITLE --support_email=SUPPORT_EMAIL\n ```\n\n\n The above fields are required when calling this API:\n - `supportEmail`: The support email displayed on the OAuth consent screen.\n This email address can either be a user's address or a Google Groups alias.\n While service accounts also have an email address, they are not actual\n valid email addresses, and cannot be used when creating a brand. However,\n a service account can be the owner of a Google Group. Either create a\n new Google Group or configure an existing group and set the desired service\n account as an owner of the group.\n\n | **Note:** The user issuing the request must be an owner of the specified support email address.\n - `applicationTitle`: The application name displayed on OAuth consent\n screen.\n\n The response contains the following fields: \n\n name: projects/[PROJECT_NUMBER]/brands/[BRAND_ID]\n applicationTitle: [APPLICATION_TITLE]\n supportEmail: [SUPPORT_EMAIL]\n orgInternalOnly: true\n\n### Creating an IAP OAuth Client\n\n1. Use the create command to\n [create](/sdk/gcloud/reference/iap/oauth-clients/create) a client. Use\n the brand `name` from previous step.\n\n ```bash\n gcloud iap oauth-clients create projects/PROJECT_NUMBER/brands/BRAND-ID --display_name=NAME\n ```\n\n The response contains the following fields: \n\n name: projects/[PROJECT_NUMBER]/brands/[BRAND_NAME]/identityAwareProxyClients/[CLIENT_ID]\n secret: [CLIENT_SECRET]\n displayName: [NAME]\n\nUse the client ID (`client_id` in the above example) and `secret` to enable\nIAP. See the following topics for more information about\nenabling IAP using the credentials you've just created:\n\n- [IAP for Kubernetes Engine](/iap/docs/enabling-kubernetes-howto)\n- [IAP for App Engine](/iap/docs/app-engine-quickstart)\n- [IAP for Compute Engine](/iap/docs/enabling-compute-howto)\n- [IAP for Cloud Run](/iap/docs/enabling-cloud-run)"]]