Java 客户端库配置

该库会在 System.getProperty("user.home") + "/searchads360.properties" 中查找配置文件。

配置文件的格式为 Java 键值对 Properties 文件。支持的密钥因所选的身份验证流程而异。

桌面应用和 Web 应用流程支持的密钥

如果您使用的是桌面或 Web 应用流程,则支持的密钥如下:

# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
api.searchads360.clientId=INSERT_CLIENT_ID_HERE

# Credential for accessing Google's OAuth servers.
# Provided by console.cloud.google.com.
api.searchads360.clientSecret=INSERT_CLIENT_SECRET_HERE

# Renewable OAuth credential associated with 1 or more Search Ads accounts.
api.searchads360.refreshToken=INSERT_REFRESH_TOKEN_HERE

# Required for manager accounts only: Specify the login customer ID used to
# authenticate API calls. This will be the customer ID of the authenticated
# manager account. You can also specify this later in code if your application
# uses multiple manager account + OAuth pairs.
#
# api.searchads360.loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE


组合使用配置方法

SearchAds360Client 及其构建器支持组合不同的配置策略。例如,您可以使用属性文件来配置实例的凭据和其他属性,如下面的代码段所示。

SearchAds360Client searchAds360Client = SearchAds360Client.newBuilder()
    .fromPropertiesFile()
    .build();

在调用 build() 之前,您可以使用构建器的其他配置方法在运行时进行进一步更改。

如果您以经理账号的身份进行身份验证,还必须指定:

api.searchads360.loginCustomerId --> Manager account ID (with hyphens removed).