Java 用戶端程式庫設定

程式庫會在 System.getProperty("user.home") + "/searchads360.properties" 中尋找設定檔。

設定檔的格式為鍵/值組合的 Java Properties 檔案。支援的金鑰會因所選的驗證流程而異。

電腦和網頁應用程式流程支援的金鑰

如果您使用電腦或網頁應用程式流程,支援的按鍵如下:

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