選擇應用程式類型
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
由於 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 帳戶的必要權限,請改用這個方法。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-05 (世界標準時間)。
[null,null,["上次更新時間:2025-09-05 (世界標準時間)。"],[],[],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|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|"]]