google-merchant-sync
v1.0.0
Published
A mountable Express router for Google Merchant Center product sync with OAuth2 support.
Downloads
5
Readme
google-merchant-sync
A mountable Express router for Google Merchant Center product sync with OAuth2 support.
Installation
npm install ./google-merchant-syncUsage
const express = require('express');
const createGoogleMerchantRouter = require('google-merchant-sync');
const app = express();
app.use(express.json());
// Make sure your authentication middleware runs before this!
app.use('/api/google-merchant', createGoogleMerchantRouter({
getUserId: req => req.user && req.user.id, // Customize as needed
// storage: { saveTokens, getTokens }, // Optionally override token storage
// successRedirect: '/dashboard' // Optional redirect after OAuth
}));
app.listen(5000, () => console.log('Server running'));Endpoints
GET /auth/initiate- Start OAuth flowGET /auth/callback- Handle OAuth callbackGET /status- Check if user is connectedPOST /sync- Sync products to Google Merchant
Token Storage
By default, tokens are stored in memory. For production, override with your own storage (e.g., database).
Environment Variables
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETGOOGLE_REDIRECT_URI
