OAuth 服务账号流程
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本指南将引导您完成以下操作:使用您自己的凭据通过服务账号设置 OAuth2 以进行 API 访问。除非您撤消或删除 OAuth2 凭据,否则只需执行一次这些步骤。
创建 OAuth2 凭据
按照关联的说明生成服务账号 ID 和 *.JSON 文件,然后返回此页面。
使用 JSON 文件设置客户端库
在 App.config / Web.config
中配置以下键。如需了解更多详情,请参阅配置指南。
<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" />
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-26。
[null,null,["最后更新时间 (UTC):2025-08-26。"],[[["\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"]]