服務帳戶是一種特殊的 Google 帳戶,可讓應用程式透過 OAuth 2.0 以程式輔助方式存取 Google API。服務帳戶使用不需要人工授權的 OAuth 2.0 流程。而是使用只有您的應用程式可以存取的金鑰檔案。本指南將說明如何使用服務帳戶存取 Content API for Shopping。
注意:使用服務帳戶進行驗證的應用程式只能存取您自己的 Merchant Center 帳戶。如果您要編寫需要存取客戶 Merchant Center 帳戶的第三方應用程式,請改為參閱「授權要求」指南。
你現在可以使用服務帳戶存取 Merchant Center 帳戶,方法是使用 Google 應用程式預設憑證流程,或是直接使用服務帳戶流程。在 Content API for Shopping 範例中,我們會說明如何在每種支援的程式設計語言中,使用服務帳戶憑證的兩種流程。請查看程式碼範例,試用新的服務帳戶,並瞭解在自己的程式碼中使用服務帳戶時,需要進行哪些變更。
常見問題
我可以使用服務帳戶登入 Merchant Center UI 嗎?
不,服務帳戶不是一般 Google 帳戶,無法存取 Merchant Center UI。
我需要多久更新一次服務帳戶存取權杖?
存取權杖會在 Google OAuth 2.0 授權伺服器核發後一小時失效。存取權杖到期時,應用程式應使用用戶端程式庫擷取其他存取權杖。
[[["容易理解","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"]],["上次更新時間:2024-11-10 (世界標準時間)。"],[[["Service accounts enable applications to programmatically access Google APIs, including the Content API for Shopping, using OAuth 2.0 without human intervention."],["To utilize service accounts, you need to generate service account credentials, add the service account as a user in your Merchant Center account, and then access your Merchant Center account using either the Google Application Default Credentials flow or the service account flow."],["Applications authenticated with service accounts can only access your own Merchant Center account; for third-party applications needing access to client accounts, refer to the Authorizing Requests guide."],["Service accounts cannot be used to sign in to the Merchant Center UI and access tokens expire after one hour, requiring the application to fetch a new one using the client library."]]],["Service accounts allow applications to access the Content API for Shopping programmatically. Key actions include: generating service account credentials by creating an OAuth 2.0 Client ID and a JSON private key file via the Google API Console, and adding the service account as a user within the Merchant Center account, specifying access and notification preferences. To access the Merchant center, you can use Google Application Default Credentials or a service account flow, with example code available. Access tokens expire hourly, requiring renewal.\n"]]