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 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 的支援團隊洽詢。

,Google Ads API 團隊

標籤: authentication、 oauth