程式庫會在 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).