API Connector Documentation
Import Google Merchant Center Data to Google Sheets
In this guide, we'll connect Google Merchant Center to Google Sheets, using the API Connector add-on for Sheets. API Connector doesn't have a native integration for this API so we'll set up a custom OAuth connection.
Contents
- Before You Begin
- Part 1: Set up Project
- Part 2: Get Credentials
- Part 3: Connect Google Merchant Center Data to API Connector
- Part 4: Pull Google Merchant Center API Data to Sheets
- Part 5: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Set up Project
- Navigate to https://console.cloud.google.com/.
- Click the project dropdown menu
- Click New Project
- Give it a name and click Create
- Still in your project, navigate to APIs & Services > Library and search for "Content API"
- Click on Content API for Shopping to open the details page, and click Enable
Part 2: Get Credentials
- You'll now be back in your project. Click Create credentials (if you aren't on this page, click Enabled APIs & Services > Content API for Shopping from the sidebar on the left)
- Fill out the Create Credentials form. It will take you through several sections, which you can fill out as follows:
- Credential Type
- Select an API:
Content API for Shopping
- What data will you be accessing:
User data
- Select an API:
- OAuth Consent Screen
- App name: enter any name
- User support email: select email address from the drop down menu
- App logo: skip or upload a logo (optional)
- Developer contact information: enter an email address
- Scopes
- Add or remove scopes:
.../auth/content
.../auth/structuredcontent
- Add or remove scopes:
- OAuth Client ID
- Application type:
web application
- Name: enter any name
- Authorized redirect URL > + ADD URI:
https://script.google.com/macros/d/12COOkin8nodCH7fZGIBu0D2jWY8-AEA0uvElt4Ph4wRbLUD4wslqQUfG/usercallback
- Application type:
- Credential Type
- Click Create
- Once you've completed those steps, click Download to download your credentials and then click Done.
Part 3: Connect Google Merchant Center to API Connector
- Open up Google Sheets and click Extensions > API Connector > Manage Connections
- Scroll to the bottom of the sidebar and click Add Custom OAuth
- Fill in the Custom OAuth modal as follows:
- OAuth Grant Type:
Authorization Code
- Name:
Custom GMC
- Authorization Base URL:
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/content
- Token URL:
https://oauth2.googleapis.com/token
- Client ID: provided by Google in the credentials file
- Client Secret: provided by Google in the credentials file
- OAuth Grant Type:
- Click Save, then click back on Manage Connections
- You should now see your new Google Merchant Center connection listed. Click Connect.
- You'll be prompted to log in and approve the connection. Click Allow.
- You can verify that your connection is now active on the Manage Connections screen.
Part 4: Pull Google Merchant Center API Data into Sheets
We're finally here....Let's get some data! You can see all the available endpoints in Google Merchant Center's documentation, but for this example we'll start with fetching product data. To do this we'll need your merchant ID, which you can get from the top menu bar while logged into the Google Merchant Center.
Once you have your merchant ID, continue as follows:
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following, substituting in your own merchant ID where it says
your_merchant_id
:- Application:
Custom
- Method:
GET
- Request URL:
https://shoppingcontent.googleapis.com/content/v2.1/your_merchant_id/products
- OAuth:
Custom GMC
- Application:
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see product data populate your Google Sheet
Part 5: API Documentation
Official API documentation: https://developers.google.com/shopping-content/reference/rest/v2.1
Error 400: redirect_uri_mismatch when I click on "Connect" with custom OAuth. Need help to resolve that. I rechecked and I have entered the correct details as mentioned above.
Please double check that the redirect URL entered when creating your app matches API Connector's redirect URL.
I did and now the error shows: Access blocked: "name - GMC" has not completed the Google verification process.
"name - GMC" has not completed the Google verification process. The app is currently being tested and can only be accessed by developer-approved testers. If you think you should have access, contact the developer.
If you are a developer of "name - GMC", see error details.
Error 403: access_denied
I have put the publishing status as testing and added the email id for test user. Now when I go through the OAuth, i get: This application was created by a Google Apps Script user.
Access Error
An error has occurred: Error: Error retrieving token: invalid_client, Unauthorized.
I just went through the process from start to finish with a new email address and project and it all worked for me as written, so I'm not sure yet what the issue is. Can you please make sure you've entered the correct client secret? In my tests, I was only able to trigger that error message when I entered an incorrect client secret, though it's possible there are other causes.
It works great for me except it will only transfer over 25 products and no more.
Hi,
You can set the query parameter "maxResults" to 250 if you have more than 25 products. If you have more than 250 products, you will have to use cursor pagination: https://mixedanalytics.com/knowledge-base/pagination-handling/#cursor. Set "Next token parameter" to "pageToken", "Next token path" to "nextPageToken", "Run until" to "response field empty", and "Response field path" to "nextPageToken".
For reference, here is the GET products endpoint documentation:
https://developers.google.com/shopping-content/reference/rest/v2.1/products/list