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).
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-03。
[null,null,["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eThe Search Ads 360 API uses a configuration file located at \u003ccode\u003eSystem.getProperty("user.home") + "/searchads360.properties"\u003c/code\u003e to store essential settings like client ID, client secret, and refresh token.\u003c/p\u003e\n"],["\u003cp\u003eThis configuration file follows the Java Properties file format and supports different keys based on the authentication method, such as desktop, web, or service application flows.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can combine configuration approaches, using the properties file for credentials and then further customizing the client using builder methods.\u003c/p\u003e\n"],["\u003cp\u003eWhen authenticating as a manager account, you need to specify the \u003ccode\u003eapi.searchads360.loginCustomerId\u003c/code\u003e in the configuration file or during client initialization.\u003c/p\u003e\n"],["\u003cp\u003eOAuth refresh tokens required for authentication can be generated using the provided user credential generation script or the OAuth Playground utility.\u003c/p\u003e\n"]]],["The library utilizes a configuration file located at `user.home/searchads360.properties`, formatted as key-value pairs. For desktop/web flows, required keys include `api.searchads360.clientId`, `api.searchads360.clientSecret`, and `api.searchads360.refreshToken`. Manager accounts also need `api.searchads360.loginCustomerId`. An OAuth refresh token can be generated via a provided script or the OAuth Playground. Configurations can be combined using the `SearchAds360Client` builder, which allows file-based configuration and runtime modifications.\n"],null,["# Java client library configuration\n\nThe library looks for a configuration file in\n`System.getProperty(\"user.home\") + \"/searchads360.properties\"`.\n\nThe format of the configuration file is that of a Java\n[Properties](//docs.oracle.com/javase/tutorial/essential/environment/properties.html)\nfile of key value pairs. The supported keys vary depending on the chosen\nauthentication flow.\n\nSupported keys for desktop and web application flows\n----------------------------------------------------\n\nIf you are using the [desktop or web](/search-ads/reporting/quickstart/quickstart-guide#create_oauth2_credentials) application flow, the supported keys\nare as follows: \n\n # Credential for accessing Google's OAuth servers.\n # Provided by console.cloud.google.com.\n api.searchads360.clientId=INSERT_CLIENT_ID_HERE\n\n # Credential for accessing Google's OAuth servers.\n # Provided by console.cloud.google.com.\n api.searchads360.clientSecret=INSERT_CLIENT_SECRET_HERE\n\n # Renewable OAuth credential associated with 1 or more Search Ads accounts.\n api.searchads360.refreshToken=INSERT_REFRESH_TOKEN_HERE\n\n # Required for manager accounts only: Specify the login customer ID used to\n # authenticate API calls. This will be the customer ID of the authenticated\n # manager account. You can also specify this later in code if your application\n # uses multiple manager account + OAuth pairs.\n #\n # api.searchads360.loginCustomerId=INSERT_LOGIN_CUSTOMER_ID_HERE\n\n\n| **Note:** You can generate an OAuth refresh token by running the provided [user credential generation script](/search-ads/reporting/sample-code/generate-user-credentials) or by using the [OAuth Playground](/search-ads/reporting/concepts/oauth-playground) utility.\n\nCombining configuration approaches\n----------------------------------\n\nThe `SearchAds360Client` and its builder support combining different configuration\nstrategies. For example, you can use a properties file to configure the\ncredentials of the instance and for other attributes using\nthe following snippet. \n\n SearchAds360Client searchAds360Client = SearchAds360Client.newBuilder()\n .fromPropertiesFile()\n .build();\n\nYou can make further changes at runtime using the builder's other configuration\nmethods before calling `build()`.\n\nIf you are authenticating as a manager account, additionally you must\nspecify: \n\n api.searchads360.loginCustomerId --\u003e Manager account ID (with hyphens removed)."]]