Google Ads API 中的同意拆分

2025 年 2 月 20 日,星期四

有何变化?
自 2025 年 5 月 1 日当周起,我们将针对 2019 年之前创建的所有 Google Cloud 项目,推出 OAuth 用户身份验证的意见征求解绑功能。如果您拥有一款应用,该应用通过 2019 年之前创建的 Google Cloud 项目使用与广告相关的 API,那么您可能需要在 2025 年 5 月 1 日之前更新应用,以处理非捆绑式用户同意。

背景
OAuth 用户身份验证流程的同意解绑功能允许用户自定义他们希望为您的应用授权哪些特定 OAuth 范围,而不是采用全有或全无的方式。自 2019 年以来创建的所有 Google Cloud 控制台项目都已启用此功能,而 2019 年之前创建的所有项目都已停用此功能。

谁会受到此项变更的影响?
如果满足以下所有条件,您将受到此变更的影响:

  1. 您的 API 应用使用的是 2019 年之前创建的 Google Cloud 控制台项目。
  2. 您的应用实现了 OAuth 2.0 用户同意流程,这是一种身份验证工作流,用户使用其 Google 账号登录,并授予您的应用请求的一项或多项权限。
  3. 您的应用使用了多个 Google API,其中一个 API 是下面列出的与 Google Ads 相关的 API。

哪些人不受此变更的影响?

  • 现有刷新令牌:此项变更不会影响您已有的用户身份验证。您现有的刷新令牌将继续有效,无需进行任何更改或重新进行身份验证。
  • 单一范围应用:如果您的应用仅使用一个 Google API 范围,则不受此变更的影响,因为没有多个 OAuth 范围需要解绑。
  • 单用户应用/手动身份验证应用:您的应用未实现明确的 OAuth 用户身份验证流程。而是使用手动身份验证脚本(例如 GenerateUserCredentials、gcloud CLI 或 OAuth Playground)对用户进行身份验证,然后长期使用这些凭据。由于您在进行身份验证时选择了应用所需的所有范围,因此您的应用不会受到此变更的影响。
  • 服务账号:如果您的应用使用服务账号对 API 调用进行身份验证,则不会受到此项变更的影响

我需要做什么?
您需要确保应用能够处理用户部分同意的情况。为此,请执行以下操作:

  1. 在 OAuth 流程中添加 include_granted_scopes 参数,请求获取用户同意的 OAuth 范围列表。
  2. 检查 OAuth 响应中用户同意的 OAuth 范围的实际列表。
  3. 在应用中实现增量授权。

请参阅我们的 OAuth 精细权限征求指南,了解处理精细权限征求的要求和最佳实践。

如何测试此功能?
您可以通过以下两种方式测试此功能:

  1. 创建新的 Google Cloud 项目:新 Google Cloud 项目已启用 OAuth 权限请求拆分。因此,您可以创建一个新的 Google Cloud 项目,并使用它来测试您的应用。
  2. 在现有项目中启用同意书解绑:您可以在 OAuth 授权请求中将 enable_granular_consent 参数设置为 true。

哪些 API 范围会受到影响?
以下与广告相关的 API 会受到此次变更的影响。

API OAuth 范围
Google Ads API https://adwords.google.com/api/adwords
Google Ad Manager API(SOAP API,Beta 版) https://www.googleapis.com/auth/dfp
https://www.googleapis.com/auth/admanager
Bid Manager API https://www.googleapis.com/auth/doubleclickbidmanager
Content API for Shopping https://www.googleapis.com/auth/content
Display & Video 360 API https://www.googleapis.com/auth/display-video-mediaplanning
https://www.googleapis.com/auth/display-video-user-management
AdMob API https://www.googleapis.com/auth/admob.report
https://www.googleapis.com/auth/admob.googlebidding.readwrite
https://www.googleapis.com/auth/admob.monetization
AdSense for Platforms API https://www.googleapis.com/auth/adsensehost
https://www.googleapis.com/auth/adsense
https://www.googleapis.com/auth/adsense.readonly
Google Analytics API https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.manage.users
https://www.googleapis.com/auth/analytics.manage.users.readonly
https://www.googleapis.com/auth/analytics.provision
https://www.googleapis.com/auth/analytics.user.deletion
Campaign Manager 360 API https://www.googleapis.com/auth/ddmconversions
https://www.googleapis.com/auth/dfareporting
https://www.googleapis.com/auth/dfatrafficking
Search Ads 360 API https://www.googleapis.com/auth/doubleclicksearch
Google Tag Manager API https://www.googleapis.com/auth/tagmanager.delete.containers
https://www.googleapis.com/auth/tagmanager.edit.containers
https://www.googleapis.com/auth/tagmanager.edit.containerversions
https://www.googleapis.com/auth/tagmanager.manage.accounts
https://www.googleapis.com/auth/tagmanager.manage.users
https://www.googleapis.com/auth/tagmanager.publish
https://www.googleapis.com/auth/tagmanager.readonly
Real-time Bidding API https://www.googleapis.com/auth/realtime-bidding
Authorized Buyers Marketplace API https://www.googleapis.com/auth/authorized-buyers-marketplace
https://www.googleapis.com/auth/adexchange.buyer

如何获取帮助
如果您有任何疑问或需要帮助,请联系相应 API 的支持团队。

标签: authentication, oauth