Para analizar nuestros productos y brindar comentarios sobre ellos, únete al canal oficial de Discord de Google Ads en el servidor de la Comunidad de Publicidad y Medición de Google.
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta guía, se explica cómo configurar OAuth2 para el acceso a la API con tus propias credenciales a través de cuentas de servicio.
Solo debes realizar estos pasos una vez, a menos que revoques o borres tus credenciales de OAuth2.
Agrega un archivo JSON de clave privada y un correo electrónico suplantado a la configuración
Establece la ruta de acceso del archivo JSON de la clave privada y el correo electrónico suplantado en tu configuración.
Si usas un archivo google-ads.yaml, una cadena YAML o dict, agrega lo siguiente:
[null,null,["Última actualización: 2025-08-27 (UTC)"],[[["\u003cp\u003eThis guide explains how to set up OAuth2 for API access using service accounts, a one-time process unless credentials are revoked.\u003c/p\u003e\n"],["\u003cp\u003eThe setup requires a Google Workspace domain and a service account with domain-wide delegation access granted by a super administrator.\u003c/p\u003e\n"],["\u003cp\u003eYou need to generate a service account ID and a JSON file, then add the private key JSON file path and impersonated email to your configuration.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration can be set using a \u003ccode\u003egoogle-ads.yaml\u003c/code\u003e file, YAML string, \u003ccode\u003edict\u003c/code\u003e, or environment variables.\u003c/p\u003e\n"],["\u003cp\u003eThe library prioritizes credentials for desktop or web app flows, so ensure these are not present if you want to use Service Account authentication.\u003c/p\u003e\n"]]],[],null,["# OAuth Service Account Flow\n\nThis guide will walk you through how to set up OAuth2 for API access using your\nown credentials with [service accounts](/google-ads/api/docs/oauth/service-accounts).\nThese steps only need to be done once, unless you revoke or delete your OAuth2\ncredentials.\n\nCreate OAuth2 credentials\n-------------------------\n\n| **Note:** This flow requires a [Google Workspace](//workspace.google.com) domain and a service account that was granted domain-wide delegation access by a super administrator for the domain.\n\n[Generate a **service account ID and a \\*.JSON\nfile**](/google-ads/api/docs/oauth/service-accounts#service_account_access_setup) by\nfollowing the linked instructions, then come back to this page.\n\nAdd a private key JSON and an impersonated email to configuration\n-----------------------------------------------------------------\n\nSet the private key JSON file path and impersonated email in your configuration.\nIf you're using a `google-ads.yaml` file, YAML string, or `dict`, add the\nfollowing: \n\n json_key_file_path: \u003cvar translate=\"no\"\u003eJSON_KEY_FILE_PATH\u003c/var\u003e\n impersonated_email: \u003cvar translate=\"no\"\u003eIMPERSONATED_EMAIL\u003c/var\u003e\n\nIf you're using environment variables, add the following to your `bash`\nconfiguration or environment: \n\n export GOOGLE_ADS_JSON_KEY_FILE_PATH=\u003cvar translate=\"no\"\u003eJSON_KEY_FILE_PATH\u003c/var\u003e\n export GOOGLE_ADS_IMPERSONATED_EMAIL=\u003cvar translate=\"no\"\u003eIMPERSONATED_EMAIL\u003c/var\u003e\n\n| **Note:** When reading in the configuration, the library first looks for credentials for the OAuth2 desktop or web app flows, and will use them if found. So if you want to use a Service Account authentication, make sure credentials for the other flows are *not* present in your configuration."]]