[null,null,["最終更新日 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."]]