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).