rocket
ขอแนะนำ
Merchant API
ซึ่งเป็นเวอร์ชันต่อไปอย่างเป็นทางการของ Content API for Shopping
update
รับข้อมูลล่าสุด
เกี่ยวกับฟีเจอร์ใหม่ การแก้ไขข้อบกพร่อง และการอัปเดตของ Merchant API
add_alert
หมายเหตุ: Content API for Shopping จะหยุดให้บริการในวันที่ 18 สิงหาคม 2026
บัญชีบริการ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
บัญชีบริการคือบัญชีพิเศษของ Google ที่แอปพลิเคชันสามารถใช้เพื่อเข้าถึง Google API แบบเป็นโปรแกรมผ่าน OAuth 2.0 บัญชีบริการใช้ขั้นตอน OAuth 2.0 ที่ไม่ต้องใช้การให้สิทธิ์จากเจ้าหน้าที่
แต่จะใช้ไฟล์คีย์ที่มีเพียงแอปพลิเคชันของคุณเท่านั้นที่เข้าถึงได้ คู่มือนี้จะอธิบายวิธีเข้าถึง Content API for Shopping ด้วยบัญชีบริการ
หมายเหตุ: แอปพลิเคชันที่ใช้บัญชีบริการเพื่อตรวจสอบสิทธิ์จะเข้าถึงได้เฉพาะบัญชี Merchant Center ของคุณเท่านั้น หากคุณเขียนแอปพลิเคชันของบุคคลที่สามที่ต้องเข้าถึงบัญชี Merchant Center ของลูกค้า โปรดดูคำแนะนำการให้สิทธิ์คำขอแทน
ข้อกำหนดเบื้องต้น
ขั้นตอนการใช้บัญชีบริการเพื่อเข้าถึง Content API for Shopping
- สร้างข้อมูลเข้าสู่ระบบของบัญชีบริการหรือเข้าถึงข้อมูลเข้าสู่ระบบสาธารณะที่คุณสร้างไว้แล้ว คุณจะต้องสร้างรหัสไคลเอ็นต์ OAuth 2.0 และรับไฟล์คีย์ส่วนตัว *.json โดยทำดังนี้
- ไปที่คอนโซล Google API
- เลือกโปรเจ็กต์ในเมนูแบบเลื่อนลงที่ด้านบนของหน้า หากยังไม่มี ให้สร้างโปรเจ็กต์โดยคลิกโปรเจ็กต์ใหม่
- หากยังไม่ได้เปิดใช้ Content API for Shopping สําหรับโปรเจ็กต์นี้ ให้ค้นหา API ดังกล่าวในรายการ Google API แล้วเปิดใช้
- เลือกข้อมูลเข้าสู่ระบบในแถบด้านข้างทางซ้าย
คุณอาจต้องคลิกลูกศรชี้ซ้ายที่ด้านซ้ายบนเพื่อดูข้อมูลนี้
- หากต้องการตั้งค่าบัญชีบริการ ให้เลือกสร้างข้อมูลเข้าสู่ระบบ แล้วเลือกบัญชีบริการ
- ตั้งชื่อบัญชีบริการใหม่ ซึ่งจะเป็นชื่อผู้ใช้เริ่มต้นสำหรับรหัสบัญชีบริการด้วย บันทึกรหัสบัญชีบริการรวมถึงส่วนที่อยู่หลังอักขระ "@" เพื่อใช้ในภายหลัง คลิกสร้าง จากนั้นทำตามขั้นตอนที่ไม่บังคับในการให้สิทธิ์เข้าถึงโปรเจ็กต์และผู้ใช้ แล้วคลิกเสร็จสิ้น
การเลือกบทบาทสําหรับบัญชีบริการจะไม่มีผลต่อสิ่งที่สามารถเรียกใช้ Content API ได้ เนื่องจากสิทธิ์เข้าถึงเมธอด Content API จะกำหนดโดยบทบาทที่เชื่อมโยงกับรหัสบัญชีบริการใน Merchant Center แทน หากไม่แน่ใจว่าควรเลือกอะไร ให้เลือกโปรเจ็กต์ > Viewer
- ระบบจะนำไปยังหน้าบัญชีบริการที่คุณใช้เข้าถึงบัญชีบริการใหม่ได้
- หากต้องการรับคีย์ส่วนตัว JSON ให้คลิกบัญชีบริการ แล้วคลิกแท็บคีย์ คลิกเพิ่มคีย์ > สร้างคีย์ใหม่ แล้วเลือก JSON เป็นประเภทคีย์ คลิกสร้างเพื่อดาวน์โหลดคีย์ส่วนตัวลงในคอมพิวเตอร์
- เพิ่มบัญชีบริการใหม่ในฐานะผู้ใช้ในบัญชี Merchant Center หากคุณเป็นนักพัฒนาซอฟต์แวร์บุคคลที่สาม คุณต้องให้ลูกค้าดำเนินขั้นตอนนี้ให้คุณ
- ไปที่บัญชี Merchant Center
- ไปที่สิทธิ์เข้าถึงบัญชีในการตั้งค่าบัญชี Merchant Center
- คลิก + เพิ่มผู้ใช้ และใช้รหัสบัญชีบริการเป็นอีเมลของผู้ใช้ใหม่
หากไม่ได้จดรหัสบัญชีบริการไว้ก่อนหน้านี้ ให้ไปที่หน้าการดูแลระบบบัญชีบริการ แล้วเลือกโปรเจ็กต์ที่คุณสร้างขึ้น
- ระบุค่ากําหนดการเข้าถึงของผู้ใช้และการแจ้งเตือนทางอีเมลสําหรับบัญชีบริการ โปรดทราบว่าการใช้บริการ
Accounts
ต้องมีสิทธิ์เข้าถึงระดับผู้ดูแลระบบ
- คลิกเพิ่มผู้ใช้เพื่อบันทึกค่ากำหนดและกลับไปยังรายชื่อผู้ใช้ รหัสบัญชีบริการควรแสดงพร้อมกับบทบาทผู้ใช้ที่เลือก
- ทำขั้นตอนนี้ซ้ำสำหรับบัญชีบริการอื่นๆ ทั้งหมดที่ต้องการเพิ่ม
- ตอนนี้คุณเข้าถึงบัญชี Merchant Center โดยใช้บัญชีบริการได้แล้วไม่ว่าจะใช้ขั้นตอนข้อมูลเข้าสู่ระบบเริ่มต้นของแอปพลิเคชัน Google หรือใช้ขั้นตอนบัญชีบริการโดยตรง ตัวอย่าง Content API for Shopping จะแสดงวิธีใช้ทั้ง 2 ขั้นตอนสำหรับข้อมูลเข้าสู่ระบบของบัญชีบริการในภาษาโปรแกรมที่รองรับแต่ละภาษา
โปรดดูตัวอย่างโค้ดเพื่อลองใช้บัญชีบริการใหม่และดูการเปลี่ยนแปลงที่คุณต้องดำเนินการเพื่อใช้บัญชีบริการในโค้ดของคุณเอง
คำถามที่พบบ่อย
- ฉันจะลงชื่อเข้าใช้ UI ของ Merchant Center ด้วยบัญชีบริการได้ไหม
- ไม่ได้ บัญชีบริการไม่ใช่บัญชี Google ปกติและเข้าถึง UI ของ Merchant Center ไม่ได้
- ฉันต้องรีเฟรชโทเค็นการเข้าถึงบัญชีบริการบ่อยแค่ไหน
- โทเค็นเพื่อการเข้าถึงจะหมดอายุใน 1 ชั่วโมงหลังจากออกโดยเซิร์ฟเวอร์การให้สิทธิ์ของ Google OAuth 2.0 เมื่อโทเค็นการเข้าถึงหมดอายุ แอปพลิเคชันควรใช้ไลบรารีไคลเอ็นต์เพื่อดึงข้อมูลโทเค็นการเข้าถึงอื่น
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 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."]]