rocket
Content API for Shopping の正式な後継である
Merchant API をご紹介します。
update
Merchant API の新機能、バグの修正、更新に関する
最新情報を入手してください。
add_alert
注: Content API for Shopping は 2026 年 8 月 18 日に廃止されます。
サービス アカウント
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
サービス アカウントは、OAuth 2.0 を介してプログラムで Google API にアクセスするために、アプリケーションによって使用される特別な Google アカウントです。サービス アカウントは、人による承認を必要としない OAuth 2.0 フローを使用します。人による承認の代わりに、該当のアプリケーションのみがアクセスできるキーファイルが使用されます。このガイドでは、サービス アカウントを使用して Content API for Shopping にアクセスする方法について説明します。
注: 認証にサービス アカウントを使用するアプリケーションは、パートナー様自身の Merchant Center アカウントにのみアクセスできます。クライアントの Merchant Center アカウントにアクセスする必要があるサードパーティ アプリケーションを作成している場合は、リクエストの承認ガイドを参照してください。
前提条件
サービス アカウントを使用して Content API for Shopping にアクセスする手順
- サービス アカウントの認証情報を生成するか、すでに生成した公開認証情報にアクセスします。OAuth 2.0 クライアント ID を作成し、*.json 秘密鍵ファイルを取得する必要があります。
- Google API コンソールに移動します。
- ページ上部のプルダウン メニューでプロジェクトを選択します。まだプロジェクトがない場合は、[新しいプロジェクト] をクリックして作成します。
- このプロジェクトで Content API for Shopping をまだ有効にしていない場合は、Google API のリストでその API を検索して有効にします。
- 左側のサイドバーで [認証情報] を選択します。左上の左矢印をクリックして表示する必要があります。
- サービス アカウントを設定するには、[認証情報を作成]、[サービス アカウント] の順に選択します。
- 新しいサービス アカウントに名前を付けます。これは、サービス アカウント ID のデフォルトのユーザー名としても機能します。後で使用できるように、サービス アカウント ID(@ の後の部分を含む)をメモしておきます。[作成] をクリックし、プロジェクトとユーザーへのアクセス権を付与するオプションの手順を行い、[完了] をクリックします。
Content API メソッドへのアクセスは、Merchant Center のサービス アカウント ID に関連付けられたロールによって決まるため、サービス アカウントのロールを選択しても、Content API への呼び出しに影響はありません。どちらを選択すればよいかわからない場合は、[プロジェクト] > [閲覧者] を選択してください。
- 新しいサービス アカウントにアクセスできる [サービス アカウント] ページが開きます。
- JSON 秘密鍵を取得するには、サービス アカウントをクリックし、[キー] タブをクリックします。[鍵を追加 > 新しい鍵を作成] をクリックし、鍵のタイプとして JSON を選択します。[作成] をクリックして、秘密鍵をパソコンにダウンロードします。
- Merchant Center アカウントに、ユーザーとして新しいサービス アカウントを追加します。サードパーティ デベロッパーの場合は、クライアントにこの手順を依頼する必要があります。
- Merchant Center アカウントに移動します。
- Merchant Center アカウントの設定で、[アカウントのアクセス] に移動します。
- [+ ユーザーを追加] をクリックし、新しいユーザーのメールアドレスとしてサービス アカウント ID を使用します。
サービス アカウント ID をメモしていない場合は、[サービス アカウント] 管理ページに移動して、作成したプロジェクトを選択します。
- サービス アカウントの [ユーザー アクセス] と [メール通知] の設定を指定します。
Accounts
サービスを使用するには、管理者権限が必要です。
- [ユーザーを追加] をクリックして設定を保存し、ユーザーのリストに戻ります。サービス アカウント ID が、選択したユーザーロールとともに表示されます。
- 追加する他のすべてのサービス アカウントに対して、この手順を繰り返します。
- これで、Google アプリケーションのデフォルト認証情報のフローを使用するか、サービス アカウントのフローを直接使用して、サービス アカウントを使用して Merchant Center アカウントにアクセスできるようになりました。Content API for Shopping のサンプルでは、サポートされている各プログラミング言語でサービス アカウント認証情報の両方のフローを利用する方法を示しています。コードサンプルをチェックし、新しいサービス アカウントを試して、独自のコードでサービス アカウントを使用する際に必要な変更を確認してください。
よくある質問
- サービス アカウントで Merchant Center の管理画面にログインできますか?
- いいえ。サービス アカウントは通常の Google アカウントではないため、Merchant Center の管理画面にアクセスできません。
- サービス アカウントのアクセス トークンはどのくらいの頻度で更新する必要がありますか?
- アクセス トークンは、Google OAuth 2.0 認証サーバーから発行されてから 1 時間後に期限切れになります。アクセス トークンの有効期限が切れると、アプリケーションはクライアント ライブラリを使用して別のアクセス トークンを取得する必要があります。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[[["\u003cp\u003eService accounts enable applications to programmatically access Google APIs, including the Content API for Shopping, using OAuth 2.0 without human intervention.\u003c/p\u003e\n"],["\u003cp\u003eTo 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.\u003c/p\u003e\n"],["\u003cp\u003eApplications 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.\u003c/p\u003e\n"],["\u003cp\u003eService 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.\u003c/p\u003e\n"]]],["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"],null,["# Service accounts are special Google accounts that can be used by\napplications to access Google APIs programmatically via OAuth 2.0. A service\naccount uses an OAuth 2.0 flow that does not require human authorization.\nInstead, it uses a key file that only your application can access. This guide\ndiscusses how to access the Content API for Shopping with service accounts.\n\n**Note:** Applications using service accounts\nfor authentication can only access your own Merchant Center account. If you are\nwriting a third-party application that needs access to your clients' Merchant\nCenter accounts, please see the [Authorizing Requests](/shopping-content/guides/how-tos/authorizing)\nguide instead.\n\nPrerequisites\n-------------\n\n- A [Merchant Center](//merchants.google.com/) account.\n\nSteps to using a service account to access the Content API for Shopping\n-----------------------------------------------------------------------\n\n1. Generate service account credentials or access the public credentials you've already generated. You will need to create an OAuth 2.0 Client ID and obtain a \\*.json private key file:\n 1. Go to the [Google API Console](https://console.cloud.google.com/apis/library).\n 2. Select a project in the drop-down menu at the top of the page. If you do not have one yet, create one by clicking **NEW PROJECT**.\n 3. If you have not already enabled the Content API for Shopping for this project, then search for it in the list of Google APIs and enable it.\n 4. In the sidebar on the left, select **Credentials**. You may need to click the left-pointing arrow at the top left to see this.\n 5. To set up a service account, select **CREATE CREDENTIALS** , and then **Service account** . \n 6. Name the new service account. This also serves as the default username for the service account ID. Record the service account ID, including the part after the '@' character, for later use. Click **CREATE** , then go through the optional steps of granting access to project and users, and click **DONE** .\n\n The choice of role for the service account will not\n have any effect on what calls can be made to the Content API, as access to\n Content API methods is determined instead by the role associated with the\n service account ID in Merchant Center. If you are unsure what to pick, just\n pick **Project \\\u003e Viewer**.\n 7. You will be directed to the Service Accounts page where your new service account can be accessed.\n 8. To obtain a JSON private key, click on the service account, then the **KEYS** tab. Click **ADD KEY \\\u003e Create new key** and then select JSON as the key type. Click **CREATE** to download the private key to your computer.\n2. Add the new service account as a user to your Merchant Center account. If you are a third-party developer, you will need to have your client do this step for you.\n 1. Go to your [Merchant\n Center account](//merchants.google.com/).\n 2. Go to **Account Access** in the settings of your Merchant Center account.\n 3. Click **+ Add user** and use the service account ID as the email address for the new user.\n\n If you did not take note of the\n service account ID earlier, go to the [Service\n Accounts](//console.developers.google.com/iam-admin/serviceaccounts/) administration page and select the project you created.\n 4. Specify the **User access** and **Email notifications** preferences for the service account. Note that the use of the `Accounts` service requires **Admin** access.\n 5. Click **Add user** to save preferences and be returned to the list of users. The service account ID should be listed with the chosen user role.\n 6. Repeat the process for all other service accounts you want to add.\n3. Now you can access your Merchant Center account using the service account either by using the [Google Application\n Default Credentials](/identity/protocols/application-default-credentials) flow or by using the [service account flow](/identity/protocols/OAuth2ServiceAccount) directly. The Content API for Shopping [Samples](/shopping-content/guides/libraries) show how to use both flows for service account credentials in each supported programming language. Please check out the code samples to try out your new service account and to learn what changes you will need to use service accounts in your own code.\n\nFrequently asked questions\n--------------------------\n\nCan I sign in to the Merchant Center UI with my service account?\n: No, service accounts are not regular Google accounts and cannot access the\n Merchant Center UI.\n\nHow often do I need to refresh service account access tokens?\n: Access tokens expire one hour after they are issued by the Google OAuth 2.0\n Authorization Server. When an access token expires, the application should use\n the client library to fetch another access token."]]