[[["容易理解","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-29 (世界標準時間)。"],[[["\u003cp\u003eThis guide explains how third-party applications can use OAuth 2.0 to access Google Merchant Center account data.\u003c/p\u003e\n"],["\u003cp\u003eApplications must be registered in the Google API Console and authorized by the user to access specific data scopes.\u003c/p\u003e\n"],["\u003cp\u003eThe authorization process involves obtaining an access token, which is then included in API requests to the Google Content API for Shopping.\u003c/p\u003e\n"],["\u003cp\u003eAll apps accessing the Content API need to be verified through a process that usually takes 3-5 business days for uninterrupted service.\u003c/p\u003e\n"],["\u003cp\u003eIncremental authorization is recommended to avoid user issues with selecting multiple data access scopes during authorization.\u003c/p\u003e\n"]]],["Applications seeking access to Google Content API for Shopping must use OAuth 2.0. The process involves registering the application with Google to obtain a client ID and secret. Applications then request specific access scopes. Users are prompted via a consent screen to authorize the requested access. Upon approval, the application receives a short-lived access token to attach to its requests. It is important to request app verification, since unverified app users will get warnings. The given PHP code demonstrates this OAuth 2.0 process.\n"],null,["# OAuth\n\n**Note:** This document describes the\nthree-legged OAuth2 flow used to request access to other parties'\ndata. Use this authentication flow if you're developing a\nthird-party application that needs access to your clients'\nMerchant Center accounts. If you are developing an in-house application that\nwill only access your own Merchant Center account, please look at\nthe [Service\nAccounts](/shopping-content/guides/how-tos/service-accounts) guide instead.\n\nEvery request your application sends to the Google Content API for Shopping must include an authorization token. The token also identifies your application to Google.\n\nAbout authorization protocols\n-----------------------------\n\nYour application must use [OAuth 2.0](https://developers.google.com/identity/protocols/OAuth2) to authorize requests. No other authorization protocols are supported. If your application uses [Sign In With Google](https://developers.google.com/identity/gsi/web), some aspects of authorization are handled for you.\n\nAuthorizing requests with OAuth 2.0\n-----------------------------------\n\nAll requests to the Google Content API for Shopping must be authorized by an authenticated user.\n\nThe details of the authorization process, or \"flow,\" for OAuth 2.0 vary somewhat depending on what kind of application you're writing. The following general process applies to all application types:\n\n1. When you create your application, you register it using the [Google API Console](https://console.cloud.google.com/). Google then provides information you'll need later, such as a client ID and a client secret.\n2. Activate the Google Content API for Shopping in the Google API Console. (If the API isn't listed in the API Console, then skip this step.)\n3. When your application needs access to user data, it asks Google for a particular **scope** of access.\n4. Google displays a **consent screen** to the user, asking them to authorize your application to request some of their data.\n5. If the user approves, then Google gives your application a short-lived **access token**.\n6. Your application requests user data, attaching the access token to the request.\n7. If Google determines that your request and the token are valid, it returns the requested data.\n\nSome flows include additional steps, such as using **refresh tokens** to acquire new access tokens. For detailed information about flows for various types of applications, see Google's [OAuth 2.0 documentation](https://developers.google.com/identity/protocols/OAuth2).\n\nHere's the OAuth 2.0 scope information for the Google Content API for Shopping:\n\n| Scope | Meaning |\n|-------------------------------------------|--------------------|\n| `https://www.googleapis.com/auth/content` | Read/write access. |\n\nTo request access using OAuth 2.0, your application needs the scope information, as well as\ninformation that Google supplies when you register your application (such as the client ID and the\nclient secret).\n\n**Tip:** The Google APIs client libraries can handle some of the authorization process for you. They are available for a variety of programming languages; check the [page with libraries and samples](/shopping-content/v2/libraries) for more details.\n\nGet OAuth scopes\n----------------\n\n\nWe recommend using [incremental\nauthorization](/identity/protocols/oauth2/web-server#incrementalAuth) to avoid problems with scope selection.\n\n\n[OAuth scopes](/identity/protocols/oauth2/scopes) are\nunselected by default in the consent screen for your app if you request more than one. When your app\npresents the consent screen to a user, they have to manually select each scope to authorize access.\n\n\nCheck the response from an OAuth request to verify that you received the appropriate scopes.\n\n\nSee the [OAuth 2.0 Policies](/identity/protocols/oauth2/policies#unbundled-consent) page\nfor more details.\n\nRequest app verification\n------------------------\n\n\nAny apps that access the Content API must go through the OAuth verification review process. Users of\nunverified apps that access the Content API will receive [warnings](//support.google.com/cloud/answer/7454865) and the apps will have [limited functionality](//support.google.com/cloud/answer/7454865#unverified-app-user-cap).\nAn app, in this context, is defined as a unique OAuth 2.0 Client ID in Google Cloud.\n\n\nThe verification process typically takes 3-5 business days to complete. To learn more about about\nthe process and to submit a request for verification, refer to [Verification for apps.](//support.google.com/cloud/answer/7454865#verification)\n\n\nThis policy applies to all apps, and we recommend that all apps undergo the Google OAuth\nverification process at their earliest convenience to avoid any business interruptions.\n\nAuthorization Example\n---------------------\n\n\nThe following code demonstrates how to configure your client and authorize requests using OAuth 2.0\nfor web applications. Other languages are available at our [Samples and Libraries](/shopping-content/guides/libraries) page. \n\nPHP\n---\n\nThis example uses the [Web Application flow](/accounts/docs/OAuth2WebServer). The redirect URI should be the URI of this PHP page. \n\n```php\n\u003c?php\nrequire_once 'Google/Client.php';\n\nsession_start();\n\n$client = new Google_Client();\n$client-\u003esetApplicationName('Sample Content API application');\n$client-\u003esetClientId('\u003cvar class=\"apiparam\" translate=\"no\"\u003eYOUR_CLIENT_ID\u003c/var\u003e');\n$client-\u003esetClientSecret('\u003cvar class=\"apiparam\" translate=\"no\"\u003eYOUR_CLIENT_SECRET\u003c/var\u003e');\n$client-\u003esetRedirectUri('\u003cvar class=\"apiparam\" translate=\"no\"\u003eYOUR_REDIRECT_URI\u003c/var\u003e');\n$client-\u003esetScopes('https://www.googleapis.com/auth/content');\n\nif (isset($_SESSION['oauth_access_token'])) {\n $client-\u003esetAccessToken($_SESSION['oauth_access_token']);\n} elseif (isset($_GET['code'])) {\n $token = $client-\u003eauthenticate($_GET['code']);\n $_SESSION['oauth_access_token'] = $token;\n} else {\n header('Location: ' . $client-\u003ecreateAuthUrl());\n exit;\n}\n```\n\nNow that you have authenticated, you can create a Service object to make API requests with. \n\n```php\nrequire_once 'Google/Service/ShoppingContent.php';\n\n$service = new Google_Service_ShoppingContent($client);\n```"]]