选择应用类型
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
由于 Google Ads 账号包含用户数据,您的应用必须获得用户的授权才能访问这些数据。根据您获取此授权的方式,大致可分为两种方法。
选择应用类型
由于 Google Ads 账号包含用户数据,因此您的应用需要获得用户的授权才能访问这些数据。根据您获取此授权的方式,大致可分为两种方法。
|
服务账号 |
用户身份验证 |
摘要 |
手动配置您的 Google Ads 账号,以授予服务账号对该账号的访问权限。之后,您的应用可以使用服务账号凭据向 Google Ads 账号发出 API 调用,而无需任何用户互动。只要服务账号有权访问 Google Ads 账号,API 调用就能正常运行。 |
从用户处获取一次性 OAuth 2.0 授权,以允许您的应用管理其 Google Ads 账号。之后,您的应用可以使用 OAuth 2.0 刷新令牌(在 OAuth 2.0 授权过程中颁发)向 Google Ads 账号发出 API 调用。只要用户不撤消授权,或者授权不会因不活动或其他原因而过期,API 调用就会正常运行。 |
易用性 |
由于应用中缺少用户授权,因此所需的配置和审批最少。 |
由于用户身份验证是应用的一部分,因此需要进行广泛的配置和审批。 |
建议 |
强烈建议作为首选方法 |
旧方法。当您无法向服务账号授予 Google Ads 账号所需的权限时,可将其用作后备选项。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[],[],null,["# Choose your application type\n\nSince Google Ads accounts contain user data, your application must obtain\nauthorization from the user to access this data. There are two broad approaches\nbased on how you obtain this authorization.\n\nChoose your app type\n--------------------\n\nSince Google Ads accounts contain user data, your app needs to obtain\nauthorization from the user to access this data. There are two broad approaches\nbased on how you obtain this authorization.\n\n| | **Service Account** | **User Authentication** |\n| Summary | Manually configure your Google Ads account to give a service account access to that account. Afterwards, your app can use the service account credentials to make API calls to the Google Ads account without any user interaction. The API calls work as long as the service account has access to the Google Ads account. | Obtain a one-time OAuth 2.0 authorization from a user to allow your app to manage their Google Ads account. Afterwards, your app can use the OAuth 2.0 refresh token (issued as part of the OAuth 2.0 authorization process) to make API calls to the Google Ads account. The API calls work as long as the user doesn't revoke the authorization, or until the authorization expires due to inactivity or other reasons. |\n| Ease of use | Minimal configuration and approvals required due to lack of user authorization in the app. | Extensive configuration and approvals required due to user authentication being part of the app. |\n| Recommendation | **Strongly recommended** as the preferred approach | Legacy approach. Use as a fallback option when you cannot give a service account the required permissions to your Google Ads account. |\n|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"]]