Dev Log
Shopify App Dev
November 6, 2025

Complete Guide to Google Merchant API Authorization for Shopify Apps

Shawn Shen avatar
Shawn Shen
Founder of Selofy
min read

Watch Video Tutorial

Introduction

Setting up Google Merchant API authorization can seem daunting, especially if you're new to Google Cloud Platform (GCP). This comprehensive guide will walk you through every step, from creating a service account to successfully authenticating your Shopify app with the Merchant API.

What you'll learn:

  • How to create and configure a Google Cloud service account
  • Two different authentication methods (with and without key files)
  • How to register your GCP project with Merchant Center
  • Common troubleshooting steps

Prerequisites:

  • A Google Cloud Platform account
  • A Google Merchant Center account
  • Basic understanding of command line operations
  • Node.js installed on your computer

Step 1: Create a Google Cloud Service Account

1.1 Access Google Cloud Console

  1. Go to Google Cloud Console
  2. Select your project (or create a new one)
  3. Navigate to IAM & Admin -> Service Accounts

1.2 Create New Service Account

  1. Click "Create Service Account"
  2. Enter a descriptive name (e.g., shopify-merchant-api)
  3. Add description: Service account for Shopify app Merchant API access
  4. Click "Create and Continue"

1.3 Assign Roles

  1. In the "Grant this service account access to project" section
  2. Add the following roles:
    • Editor (for general project access)
    • Service Account User (for authentication)
  3. Click "Continue" then "Done"

Step 2: Add Service Account to Merchant Center (Recommended Method)

This is the easiest and most secure approach. No key files needed!

2.1 Get Your Service Account Email

  1. In Google Cloud Console, go to Service Accounts
  2. Find your newly created service account
  3. Copy the email address (it looks like: your-service-account@your-project.iam.gserviceaccount.com)

2.2 Add to Merchant Center

  1. Go to Google Merchant Center
  2. Navigate to Settings -> Account access -> Users
  3. Click "Add User"
  4. Enter your service account email
  5. Select "Admin" role
  6. Click "Save"

Important: Wait 5-10 minutes for permissions to propagate.

Step 3: Install Required Dependencies

Create a new directory for your project and install the necessary packages:

mkdir merchant-api-auth
cd merchant-api-auth
npm init -y
npm install google-auth-library axios

Step 4: Create the Registration Script

Create a file called register-gcp-developer.js:

const { GoogleAuth } = require('google-auth-library');
const axios = require('axios');

// Configuration
const MERCHANT_ID = 'YOUR_MERCHANT_ID'; // Replace with your Merchant Center ID
const DEVELOPER_EMAIL = 'your-email@gmail.com'; // Replace with your email
const GCP_PROJECT_ID = 'your-project-id'; // Replace with your GCP project ID

async function registerGcpDeveloper() {
    try {
        console.log('🔐 Authenticating with Google Cloud...');

        // Initialize Google Auth
        const auth = new GoogleAuth({
            scopes: ['[https://www.googleapis.com/auth/content](https://www.googleapis.com/auth/content)'],
        });

        // Get authenticated client
        const authClient = await auth.getClient();

        console.log('✅ Authentication successful');
        console.log('📡 Registering GCP project with Merchant Center...');

        // Prepare API request
        const url = `https://merchantapi.googleapis.com/accounts/v1beta/accounts/${MERCHANT_ID}/developerRegistration:registerGcp`;
        const requestBody = {
            developerEmail: DEVELOPER_EMAIL
        };

        // Make API request
        const response = await authClient.request({
            url: url,
            method: 'POST',
            data: requestBody,
        });

        console.log('✅ Registration successful!');
        console.log('📋 Response:', JSON.stringify(response.data, null, 2));
        console.log('\n>>> Your Shopify app can now access Merchant API! <<<');

    } catch (error) {
        console.error('❌ Registration failed:', error.message);
        if (error.response) {
            console.error('📋 Error details:', JSON.stringify(error.response.data, null, 2));
        }
    }
}

// Run the registration
registerGcpDeveloper();


Step 5: Authenticate and Run the Script

Method 1: Using gcloud CLI (Recommended)

  1. Install Google Cloud CLI:
  2. Authenticate:

gcloud auth application-default login

This will open a browser window for authentication.

  1. Run the script:

node register-gcp-developer.js

Method 2: Using Service Account Key File (Fallback)

If Method 1 doesn't work, use this approach:

  1. Download Service Account Key:
    • Go to Google Cloud Console -> Service Accounts
    • Click on your service account
    • Go to Keys tab -> Add Key -> Create New Key
    • Choose JSON format and download
  2. Place the key file:
    • Rename the downloaded file to service-account-key.json
    • Place it in your project directory
  3. Update your script:Add this line at the top of your script:

process.env.GOOGLE_APPLICATION_CREDENTIALS = './service-account-key.json';

  1. Run the script:

node register-gcp-developer.js

Step 6: Verify Success

When successful, you should see output like:

✅ Registration successful!
📋 Response: {
"name": "accounts/YOUR_MERCHANT_ID/developerRegistration",
"gcpIds": [
"YOUR_GCP_PROJECT_NUMBER"
]
}


Troubleshooting Common Issues

Issue 1: "Request had insufficient authentication scopes"

Solution: Ensure your service account has the correct roles and is added to Merchant Center as an Admin user.

Issue 2: "The caller does not have access to the accounts"

Solution:

  1. Verify the service account email is added to Merchant Center
  2. Wait 5-10 minutes for permissions to propagate
  3. Ensure you're using the correct Merchant ID

Issue 3: "gcloud command not found"

Solution:

  1. Install Google Cloud CLI properly
  2. Restart your terminal/command prompt
  3. Use Method 2 (key file) as an alternative

Issue 4: "Authentication failed"

Solution:

  1. Run gcloud auth application-default login again
  2. Ensure you're logged in with the correct Google account
  3. Check that your service account has proper roles

Security Best Practices

  1. Never commit key files to version control
    • Add service-account-key.json to your .gitignore
  2. Use environment variables in production:

const MERCHANT_ID = process.env.MERCHANT_ID;
const DEVELOPER_EMAIL = process.env.DEVELOPER_EMAIL;

  1. Regularly rotate service account keys
    • Delete old keys after creating new ones
  2. Use least privilege principle
    • Only grant necessary permissions to service accounts

Next Steps

Once registration is complete, you can:

  1. Start making Merchant API calls from your Shopify app
  2. Implement product feed management
  3. Set up automated inventory synchronization
  4. Build custom reporting dashboards

Conclusion

Setting up Google Merchant API authorization might seem complex initially, but following this step-by-step guide ensures a smooth setup process. The key is properly configuring your service account and adding it to Merchant Center with appropriate permissions.

Remember: Method 1 (using gcloud CLI) is more secure and easier to maintain than Method 2 (key files). Always prefer the CLI approach when possible.

Frequently Asked Questions

Related Blogs
Cloud Proxy API Service Deployment Guide logo Image
Dev Log
Shopify App Dev
Cloud Proxy API Service Deployment Guide
How to Self‑Host a Stable Shopify App Dev Tunnel with FRP + Cloudflared (Fixed Port Mode) logo Image
Dev Log
Shopify App Dev
How to Self‑Host a Stable Shopify App Dev Tunnel with FRP + Cloudflared (Fixed Port Mode)
How to Deploy a Shopify App to VPS Using Dokploy: Complete Guide logo Image
Dev Log
Shopify App Dev
How to Deploy a Shopify App to VPS Using Dokploy: Complete Guide
How to Deploy FRP on Dokploy Platform logo Image
Dev Log
Shopify App Dev
How to Deploy FRP on Dokploy Platform
Configuring Fixed Port for Shopify App Dev Tunnel (Vite Modification) logo Image
Dev Log
Shopify App Dev
Configuring Fixed Port for Shopify App Dev Tunnel (Vite Modification)
Shopify App Dev Localhost Error: Invalid Webhook URI Fix logo Image
Dev Log
Dev Log
Shopify App Dev Localhost Error: Invalid Webhook URI Fix
How I Built an E-commerce Toolkit with Zero Coding Experience - Dev Log #001 logo Image
Dev Log
Dev Log
How I Built an E-commerce Toolkit with Zero Coding Experience - Dev Log #001