Page Summary
-
Clients can be configured using a YAML file, environment variables, a YAML string, or a Python dictionary.
-
Configuration using a YAML file can be loaded from a default location or a specified path using
load_from_storage. -
Client configuration can be stored as environment variables, which are read using the
load_from_envmethod. -
You can load configuration directly from a YAML string using
load_from_stringor from a Python dictionary usingload_from_dict. -
Various configuration fields are available for general settings, authentication, and logging.
There are multiple different ways to configure the client.
Authentication configuration
There are multiple ways to manage the OAuth credentials needed to access the Google Ads API. The approach you choose will affect which configuration fields you use. For more information see our authentication guide.
Configuration using YAML file
You can specify a YAML file to use when initializing the client that contains
the necessary information needed to make requests to the Google Ads API. This
file is accessed when a client is initialized using the load_from_storage
method. The easiest way to generate this file is to copy the
google-ads.yaml
example from the GitHub repository and modify it to include your credentials,
including your refresh token, client ID, and client secret.
If you don't provide a path, the library will look in your $HOME directory
for the file:
from google.ads.googleads.client import GoogleAdsClient
client = GoogleAdsClient.load_from_storage()
To specify a location where the google-ads.yaml file is located, you can pass
the path as a string to the method when calling it:
from google.ads.googleads.client import GoogleAdsClient
client =