Proxy configuration

  • The Java client library allows setting up proxy configurations for connecting to the API.

  • Standard Java proxy settings are used for configuring proxies.

  • Both HTTPS and HTTP proxies can be configured using system properties.

  • Runtime configuration of proxy settings is possible.

  • Service clients must be recreated after changing proxy settings at runtime.

The Google Ads API Java client library uses gRPC for transport and supports standard Java system proxy settings for connecting to the API.

Settings

The library supports the standard networking and proxy properties for Java.

Command-line configuration

For an HTTPS proxy, pass the following JVM arguments at application startup:

-Dhttps.proxyHost=HOST -Dhttps.proxyPort=PORT

For an HTTP proxy (not recommended unless you're providing your own local HTTP proxy endpoint), set the proxy configuration as:

-Dhttp.proxyHost=HOST -Dhttp.proxyPort=PORT

Programmatic configuration

You can also configure HTTP and HTTPS proxy properties programmatically at runtime before creating your service clients:

System.setProperty("https.proxyHost", "HOST");
System.setProperty("https.proxyPort", "PORT");

Proxy authentication and bypass

If your proxy server requires authentication or host exclusions, specify the additional JVM proxy properties:

-Dhttps.proxyUser=USERNAME \
-Dhttps.proxyPassword=PASSWORD \
-Dhttp.nonProxyHosts="localhost|127.0.0.1"