Luồng tài khoản dịch vụ OAuth
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ạo thông tin đăng nhập OAuth2
Tạo mã nhận dạng tài khoản dịch vụ và tệp *.JSON bằng cách làm theo hướng dẫn được liên kết, sau đó quay lại trang này.
Thiết lập thư viện ứng dụng bằng tệp JSON
Định cấu hình các khoá sau trong App.config / Web.config
. Hãy xem hướng dẫn về cấu hình để biết thêm thông tin chi tiết.
<add key="OAuth2Mode" value="SERVICE_ACCOUNT" />
<add key="OAuth2SecretsJsonPath" value="INSERT_OAUTH2_SECRETS_JSON_FILE_PATH_HERE" />
<!-- Supply the email address of the user to impersonate if using impersonation. -->
<add key="OAuth2PrnEmail" value="INSERT_OAUTH2_USER_EMAIL_HERE" />
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-26 UTC."],[[["\u003cp\u003eThe Google Ads API client library for .NET will no longer support .NET 5.0 starting with version 19.0.0, and upgrading before the end of 2024 is recommended.\u003c/p\u003e\n"],["\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 granted to the service account.\u003c/p\u003e\n"],["\u003cp\u003eUsers need to generate a service account ID and JSON file before proceeding with client library configuration.\u003c/p\u003e\n"],["\u003cp\u003eConfiguration involves setting keys in \u003ccode\u003eApp.config\u003c/code\u003e or \u003ccode\u003eWeb.config\u003c/code\u003e, including OAuth2Mode, OAuth2SecretsJsonPath, and OAuth2PrnEmail.\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[Generate a **service account ID and a \\*.JSON\nfile**](/google-ads/api/docs/oauth/service-accounts#service_account_access_setup) by\nfollowing the linked instructions, then come back to this page.\n\nSet up client library with JSON file\n------------------------------------\n\nConfigure the following keys in your `App.config / Web.config`. See the\n[configuration guide](/google-ads/api/docs/client-libs/dotnet/configuration) for additional\ndetails. \n\n \u003cadd key=\"OAuth2Mode\" value=\"SERVICE_ACCOUNT\" /\u003e\n \u003cadd key=\"OAuth2SecretsJsonPath\" value=\"INSERT_OAUTH2_SECRETS_JSON_FILE_PATH_HERE\" /\u003e\n\n \u003c!-- Supply the email address of the user to impersonate if using impersonation. --\u003e\n \u003cadd key=\"OAuth2PrnEmail\" value=\"INSERT_OAUTH2_USER_EMAIL_HERE\" /\u003e"]]