Ads API Client library provides several configuration settings that you can use to customize the library behavior.

Configuration file

You can specify a file to use when instantiating the client.

If you use no arguments when instantiating:

my $api_client = Google::Ads::GoogleAds::Client->new();

then the library will look in your HOME directory for the file.

Alternatively, you can specify a path:

my $properties_file = "/path/to/";

my $api_client = Google::Ads::GoogleAds::Client->new({
  properties_file => $properties_file

in which case the client will look for the file at that file path.

The easiest way to generate this file is to copy the from the GitHub repository and modify it to include your client ID, client secret and refresh token.

Dynamic configuration

You can set up the configuration dynamically when instantiating the library, or even afterwards:

my $api_client = Google::Ads::GoogleAds::Client->new({
  developer_token   => "INSERT_DEVELOPER_TOKEN_HERE",
  login_customer_id => "INSERT_LOGIN_CUSTOMER_ID_HERE"

You can even modify the configuration after instantiation:


You can also get a OAuth2ApplicationsHandler object from the API Client, and change the client ID, client secret and refresh token at runtime:

my $oauth2_applications_handler = $api_client->get_oauth2_applications_handler();

Configuration environment variables

You can set some of the configuration settings from environment variables when instantiating clients (see the exhaustive list).

The Client module provides the configure_from_environment_variables function to load values from environment variables:

# Get the Google Ads Client. By default, any credentials will be read from
# ~/, or, if set, from the file specified in the
my $api_client = Google::Ads::GoogleAds::Client->new();

# Load the configuration from any set environment variables.

Configuration fields

The configuration properties support the following fields:

Fields persisted in OAuth2ApplicationsHandler:

  • client_id: Your OAuth2 client ID.
  • client_secret: Your OAuth2 client secret.
  • refresh_token: Your OAuth2 refresh token.

Fields persisted in API Client:

  • developer_token: Your developer token for accessing the API.
  • login_customer_id: See the login-customer-id documentation.
  • proxy: The proxy server URL used for internet connectivity.