Java 用戶端程式庫設定

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

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

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

如果您使用桌面或網頁應用程式流程,支援的金鑰如下:

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