Configuration

Configuration is done through the Config class. You can access this class in multiple ways.

Configuration file

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

If you use no arguments when instantiating:

client = Google::Ads::GoogleAds::GoogleAdsClient.new

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

Alternatively, you can specify a path:

client = Google::Ads::GoogleAds::GoogleAdsClient.new("path/to/file.rb")

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

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

Dynamic configuration

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

client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config|
  config.client_id = 'INSERT_CLIENT_ID_HERE'
  # ... more configuration
end

You can even modify the configuration after instantiation:

client.config do |config|
  config.login_customer_id = 'INSERT_LOGIN_CUSTOMER_ID_HERE'
  # ... more configuration
end

Configuration Fields

The Config object supports the following fields.

General fields:

  • refresh_token: Your OAuth refresh token.
  • client_id: Your OAuth client ID.
  • client_secret: Your OAuth client secret.
  • developer_token: Your developer token for accessing the API.
  • login_customer_id: See the login-customer-id documentation.

Logging fields. See the logging guide for complete details.

  • log_level: The minimum log level messages you want logged. For example, specifying 'DEBUG' will ensure you see all log messages, and specifying 'INFO' will exclude DEBUG messages but show all other messages.
  • log_target: Where you want to log to, such as STDERR.
  • logger: Specify your own custom logger. Specifying this will override both log_level and log_target.

Send feedback about...

Google Ads API
Google Ads API
Need help? Visit our support page.