Class GoogleAdsClient

java.lang.Object
com.google.ads.googleads.lib.AbstractGoogleAdsClient
com.google.ads.googleads.lib.GoogleAdsClient
All Implemented Interfaces:
GoogleAdsAllVersions

@Immutable @ThreadSafe public abstract class GoogleAdsClient extends AbstractGoogleAdsClient
A client for the Google Ads API that handles common configuration and OAuth2 settings.

Instances of this class are both immutable and thread safe.

Implements GoogleAdsAllVersions to simplify instantiation of service client objects using the GoogleAdsClient as a TransportChannelProvider and default service settings, as shown in the following example.

 
 GoogleAdsClient googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build();
 try (CampaignServiceClient client = googleAdsClient.getLatestVersion().getCampaignServiceClient()) {
   ...
 }
 
 
  • Constructor Details

    • GoogleAdsClient

      public GoogleAdsClient()
  • Method Details

    • newBuilder

      public static GoogleAdsClient.Builder newBuilder()
      Returns a new builder for GoogleAdsClient with only default values set.
    • getCredentials

      @Nullable public abstract com.google.auth.Credentials getCredentials()
      Returns the credentials for this client.

      This field is marked nullable to enable proper builder behavior. In practice, all requests to Google Ads API must be authenticated, and this field will never be null.

    • getDeveloperToken

      @Nullable public abstract String getDeveloperToken()
      Returns the developer token.
    • getEndpoint

      public abstract String getEndpoint()
      Returns the endpoint to use. Defaults to DEFAULT_ENDPOINT.
    • getLoginCustomerId

      @Nullable public abstract Long getLoginCustomerId()
      Returns the login customer ID for this client.
    • getLinkedCustomerId

      @Nullable public abstract Long getLinkedCustomerId()
      Returns the linked customer ID for this client. Only required if explicitly instructed by the service documentation.
    • getMaxInboundMessageBytes

      @Nullable public abstract Integer getMaxInboundMessageBytes()
      Returns the maximum size of inbound gRPC messages, in bytes.
    • toBuilder

      public abstract GoogleAdsClient.Builder toBuilder()
      Returns a new GoogleAdsClient.Builder with the properties as this instance.