Để thảo luận và đưa ra ý kiến phản hồi về các sản phẩm của chúng tôi, hãy tham gia kênh Discord chính thức của Google Ads trong máy chủ Cộng đồng quảng cáo và đo lường của Google.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Hướng dẫn này sẽ hướng dẫn bạn cách thiết lập OAuth2 để truy cập API bằng thông tin xác thực của riêng bạn thông qua tài khoản dịch vụ.
Bạn chỉ cần thực hiện các bước này một lần, trừ phi bạn thu hồi hoặc xoá thông tin đăng nhập OAuth2.
Đặt đường dẫn tệp JSON khoá riêng tư và mã nhận dạng tài khoản uỷ quyền trong cấu hình của bạn. Nếu bạn đang sử dụng tệp googleads.properties, hãy thêm nội dung sau:
[null,null,["Cập nhật lần gần đây nhất: 2025-08-27 UTC."],[[["\u003cp\u003eThis guide explains how to set up OAuth2 for API access using service accounts, requiring a Google Workspace domain and domain-wide delegation access.\u003c/p\u003e\n"],["\u003cp\u003eYou need to generate a service account ID and JSON file before configuring the client library for service account authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe client library setup involves providing the private key JSON file path and delegate account ID in your configuration file or environment variables.\u003c/p\u003e\n"],["\u003cp\u003eEnsure no OAuth2 desktop or web app flow credentials are present in your configuration to prioritize Service Account authentication.\u003c/p\u003e\n"]]],[],null,["# OAuth Service Account Flow\n\nThis guide will walk you through how to setup OAuth2 for API access using your\nown credentials using [service accounts](/google-ads/api/docs/oauth/service-accounts).\nThese steps only need to be done once, unless you revoke or delete your OAuth2\ncredentials.\n\nCreate OAuth2 credentials\n-------------------------\n\n| **Note:** This flow requires a [Google Workspace](//workspace.google.com) domain and the service account that you created needs to be granted domain wide delegation access by a super administrator for the domain.\n\n[Generate a service (delegate) account ID and a `*.JSON`\nfile](/google-ads/api/docs/oauth/service-accounts#service_account_access_setup)\nby following the linked instructions, then come back to this page.\n\nSet up client library\n---------------------\n\nSet the private key JSON file path and delegate account ID in your\nconfiguration. If you're using a `googleads.properties` file, add the following: \n\n jsonKeyFilePath=\u003cvar translate=\"no\"\u003ePRIVATE_KEY_FILE_PATH\u003c/var\u003e\n impersonatedEmail=\u003cvar translate=\"no\"\u003eDELEGATE_ACCOUNT\u003c/var\u003e\n\nIf you're using environment variables, add the following to your Bash\nconfiguration or environment: \n\n export GOOGLE_ADS_JSON_KEY_FILE_PATH=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePRIVATE_KEY_FILE_PATH\u003c/span\u003e\u003c/var\u003e\n export GOOGLE_ADS_IMPERSONATED_EMAIL=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eDELEGATE_ACCOUNT_ID\u003c/span\u003e\u003c/var\u003e\n\n| **Key Point:** When loading configurations, the library first looks for credentials from the OAuth2 desktop or web app flows, and then uses them if found. So if you want to use a Service Account authentication, make sure credentials for the other flows are *not* present in your configuration."]]