[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-27 (世界標準時間)。"],[[["\u003cp\u003eThis guide is for advanced users familiar with OAuth 2.0 and its use with Google APIs, offering behind-the-scenes details on authentication with the Google Ads API.\u003c/p\u003e\n"],["\u003cp\u003eAccess tokens control API access, determined by the 'scope' parameter, with the Google Ads API scope being \u003ccode\u003ehttps://www.googleapis.com/auth/adwords\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eOffline access is available for client apps; web apps require setting \u003ccode\u003eaccess_type\u003c/code\u003e to \u003ccode\u003eoffline\u003c/code\u003e, while desktop apps have it enabled by default.\u003c/p\u003e\n"],["\u003cp\u003eAccess tokens are passed via the \u003ccode\u003eAuthorization\u003c/code\u003e HTTP header for REST or bound to a \u003ccode\u003eChannel\u003c/code\u003e for gRPC, and can be refreshed using a securely stored refresh token.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries automatically handle token refresh, but developers can consult guides for desktop and web app token management.\u003c/p\u003e\n"]]],[],null,["# OAuth2 Internals for Google Ads API\n\nOur client libraries automatically take care of the details covered below, so\ncontinue reading only if you're interested in what's happening behind the\nscenes, or if you're not using one of our client libraries.\n\nThis section is intended for advanced users who are already familiar\nwith the [OAuth 2.0 specification](//tools.ietf.org/html/rfc6749) and\nknow how to [use OAuth2 with Google APIs](/identity/protocols/oauth2).\n| **Note:** The Google Ads API does not currently support simultaneous signin with data access request (hybrid) or domain-wide delegation of authority (2LO).\n\n#### Want to learn more about authentication in the API?\n\n\nvideo_library\n[Video library: Authentication and Authorization](/google-ads/api/videos/catalog#authentication-authorization)\n\nScope\n-----\n\nA single access token can grant varying degrees of access to multiple APIs. A\nvariable parameter called `scope` controls the set of resources and operations\nthat an access token permits. During the access token request, your app\nsends one or more values in the `scope` parameter.\n\nThe scope for the Google Ads API is: \n\n https://www.googleapis.com/auth/adwords\n\nOffline access\n--------------\n\nIt's common for a Google Ads API client app to request offline access. For example,\nyour app may want to run batch jobs when your user is not physically online\nbrowsing your website.\n\nTo request offline access for a web app type, make sure you set the\n`access_type` parameter to `offline`. You can find additional information in\n[Google's OAuth2 guide](/identity/protocols/oauth2/web-server#offline).\n\nFor the desktop app type, offline access is enabled by default---you\ndon't have to explicitly request it.\n\nRequest headers\n---------------\n\n### gRPC headers\n\nWhen using the gRPC API, include the access token in each request. You can bind\na `Credential` to a `Channel` for use on all requests on that channel. You can\nalso send a customized credential for each call. The [gRPC\nAuthorization guide](//grpc.io/docs/guides/auth.html) contains more\ndetails on handling authorization.\n\n### REST headers\n\nWhen using the REST API, pass the access token through the HTTP header\n`Authorization`. An example HTTP request is shown below: \n\n```http\nGET /v21/customers/\u003cvar translate=\"no\"\u003e123456789\u003c/var\u003e HTTP/2\nHost: googleads.googleapis.com\nUser-Agent: INSERT_USER_AGENT\nAccept: */*\nAuthorization: Bearer \u003cvar translate=\"no\"\u003eINSERT_ACCESS_TOKEN\u003c/var\u003e\ndeveloper-token: INSERT_DEVELOPER_TOKEN\n```\n\nAccess and refresh token\n------------------------\n\nIn most cases, you need to store the refresh token securely for future use.\nTo learn more about how to request access and refresh tokens, read the\ncorresponding guide for your application type:\n\n- [Desktop app](/identity/protocols/oauth2/native-app)\n- [Server-side web app](/identity/protocols/oauth2/web-server)\n\nRefresh token expiration\n------------------------\n\nFor more details about the refresh token expiration, refer to the [Google\nIdentity Platform OAuth documentation](/identity/protocols/oauth2#expiration).\n\nAccess token expiration\n-----------------------\n\nAn access token has an expiration time (based on the\n[`expires_in`](//tools.ietf.org/html/rfc6749#appendix-A.14) value) after\nwhich the token is no longer valid. You can use the refresh token to refresh\nan expired access token. By default, our client libraries automatically\nrefresh expired access tokens."]]