Google Ads API is returning to beta status. Please read our blog post for more details.

Configuration

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

Configuration file

You can specify a googleads.properties 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/googleads.properties";

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 googleads.properties from the GitHub repo 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:

$api_client->set_login_customer_id("INSERT_LOGIN_CUSTOMER_ID_HERE");

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

my $oauth_2_applications_handler = $api_client->get_oauth_2_applications_handler();
$oauth_2_applications_handler->set_client_id("INSERT_CLIENT_ID");
$oauth_2_applications_handler->set_client_secret("INSERT_CLIENT_SECRET");
$oauth_2_applications_handler->set_refresh_token("INSERT_REFRESH_TOKEN");

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.