🚀 Ultimate Guide: How to Sync Firebase Auth Users to Google Sheets Automatically with n8n.

Sync ALL Firebase Auth Users to Google Sheets (Handles 1000+ Users) | n8n Tutorial

🚀 Ultimate Guide: Sync ALL Firebase Auth Users to Google Sheets (Handles 1000+ Users) — No Code, Just n8n!

No Firestore. No Backend. No Servers. Just pure Firebase Auth → n8n → Google Sheets — with pagination!

Perfect for: Newsletter creators, SaaS founders, Marketing teams, Indie hackers, Automation geeks

📅 Updated: April 2025 | 🛠️ Tools: Firebase Auth, n8n, Google Sheets, Service Account API

🌟 Why This Matters

You built a website. Users sign up with Google. Firebase Auth stores them securely.

But… you can’t see them — especially if you have 1000+ users.

Firebase Auth API returns max 1000 users per call. Without pagination, you miss data.

This workflow:

  • ✅ Fetches ALL users (even 10,000+)
  • ✅ Automatically paginates through results
  • Upserts into Google Sheets (no duplicates)
  • ✅ Runs daily, automatically

All in n8n — no code, no backend.

🧰 What You’ll Build

  1. Schedule Trigger → Runs daily at midnight
  2. Initialize State → Prepares pageToken, allUsers[]
  3. HTTP Request → Fetches 1000 users per page from Firebase Auth API
  4. Merge & Check Pagination → Merges current page + checks if more pages exist
  5. Loop Back → If hasMore = true, fetch next page
  6. Format Final Data → Clean, readable columns
  7. Google Sheets → Upsert by Email (no duplicates!)

📦 Tools You Need

Tool Why Free?
Firebase Stores your users ✅ Yes
n8n Automates everything visually + code ✅ Free tier
Google Sheets Your user database ✅ Yes
💡 No coding skills needed. Just copy-paste and click.

🧭 STEP-BY-STEP: UPDATED WORKFLOW

All nodes are connected in order. Execute each step to test.

✅ STEP 0: One-Time Setup

A. Create Your Google Sheet

  1. Go to sheets.google.com
  2. Create a new sheet → Name it: Firebase Auth Users
  3. In Row 1, add headers:
    exportedAt | uid | email | displayName | phoneNumber | emailVerified | disabled | createdAt | lastLoginAt
  4. Click Share → Get shareable link → Set to “Anyone with link can edit” (for testing)
📌 These headers must match the final formatted output.

B. Set Up n8n Credentials

  1. Go to n8n.cloud → Sign up (free)
  2. Go to CredentialsAdd Credential
  3. Add “Google Service Account API”
    • Credential Type: Firebase Admin SDK
    • Paste your Firebase Service Account JSON (from Console → Project Settings → Service Accounts)
    • Save as: Firebase Auth API
  4. Add Google Sheets OAuth → Connect your Google Account → Allow access

🧩 STEP 1: Build the Workflow

➤ NODE 1: Schedule Trigger (Run Daily)

  • Add “Cron” node
  • Mode: Every Day
  • Timezone: Asia/Kolkata (or your timezone)
  • Time: 00:05
  • Name: Daily Trigger
✅ This starts your workflow every day at 12:05 AM.

➤ NODE 2: Function → Initialize Pagination State

  • Add “Function” node → Connect from Cron
  • Name: Initialize State
return [{
  json: {
    pageToken: null,        // Start from first page
    allUsers: [],           // Empty array to accumulate users
    project_id: "fir-fb08a" // ← REPLACE WITH YOUR PROJECT ID
  }
}];
✅ Replace fir-fb08a with your actual Firebase Project ID.

➤ NODE 3: HTTP Request → Fetch Users (Paginated)

  • Add “HTTP Request” node → Connect from Function
  • Name: Fetch Auth Users Page
  • Method: POST
  • URL: https://identitytoolkit.googleapis.com/v1/projects/{{$json.project_id}}/accounts:query
  • Authentication: Predefined Credential Type
    • Credential Type: Google Service Account API
    • Credential: Firebase Auth API
Headers:
NameValue
AuthorizationBearer {{$json.accessToken}}
Content-Typeapplication/json
Body (JSON):
{
  "maxResults": 1000,
  {{ $json.pageToken ? '"pageToken": "' + $json.pageToken + '",' : '' }}
  "returnUserInfo": true
}
💡 This dynamically adds pageToken if it exists.

➤ NODE 4: Function → Merge Users + Check Pagination

  • Add “Function” node → Connect from HTTP Request
  • Name: Merge Users & Check Next Page
const newUsers = $input.item.json.users || [];
const existingUsers = $input.item.json.allUsers || [];
const mergedUsers = [...existingUsers, ...newUsers];
const nextPageToken = $input.item.json.nextPageToken || null;
const hasMore = !!nextPageToken;

return {
  ...$input.item.json,
  allUsers: mergedUsers,
  pageToken: nextPageToken,
  hasMore: hasMore
};
✅ Output includes hasMore: true/false → used for looping.

➤ NODE 5: IF → Check if More Pages Exist

  • Add “IF” node → Connect from Function
  • Name: More Pages?
  • Condition:
    • Value 1: hasMore
    • Operation: is equal to
    • Value 2: true
🔄 Connect TRUE output → back to “Fetch Auth Users Page” (Node 3)
🔄 Connect FALSE output → to next step (formatting)

➤ NODE 6: Function → Format Final User Data

  • Add “Function” node → Connect from IF → FALSE
  • Name: Format Users for Sheets
return ($input.item.json.allUsers || []).map(user => ({
  exportedAt: new Date().toISOString(),
  uid: user.localId,
  email: user.email || '',
  displayName: user.displayName || '',
  phoneNumber: user.phoneNumber || '',
  emailVerified: user.emailVerified ? 'Yes' : 'No',
  disabled: user.disabled ? 'Yes' : 'No',
  createdAt: user.createdAt ? new Date(parseInt(user.createdAt)).toISOString() : '',
  lastLoginAt: user.lastLoginAt ? new Date(parseInt(user.lastLoginAt)).toISOString() : ''
}));
✅ Output: Clean array of objects ready for Google Sheets.

➤ NODE 7: Google Sheets → Upsert by Email

  • Add “Google Sheets” node → Connect from Function
  • Operation: Append or Update Row
  • Document: By ID → Paste your Sheet ID (from URL)
  • Sheet Name: Select your sheet (e.g., Firebase Auth Users)
  • Mapping Column Mode: Map Automatically
  • Column to Match On: email ← Prevents duplicates!
  • Credentials: Your Google Sheets OAuth credential
✅ Execute → All users (even 10,000+) appear in your sheet — no duplicates!

🧠 PRO TIPS & BEST PRACTICES

➤ Handle Rate Limits

Add a “Wait” node (1-2 sec) between page fetches if you hit rate limits.

➤ Add Error Handling

Use “Catch” node → log failed pages to another sheet.

➤ Schedule Weekly for Large Datasets

If you have 50k+ users, run weekly to avoid timeouts.

➤ Add “Last Sync” Column

In Sheet → add column → ={{ $now }} → track when sync ran.

🚫 COMMON ERRORS & FIXES

ErrorFix
403 Permission DeniedEnsure Service Account has “Firebase Auth Viewer” role in Google Cloud IAM
Invalid Page TokenReset pageToken: null in Initialize State
Column MismatchEnsure Sheet headers exactly match formatted output
TimeoutIncrease timeout in HTTP Request node → 300000 ms

🎁 BONUS: DOWNLOAD WORKFLOW JSON

Want to import this workflow directly into n8n?

👉 Download Workflow JSON (placeholder — you can export from n8n)

💬 FINAL THOUGHTS

You just built an enterprise-grade, scalable, no-code user sync system.

Handles pagination. Prevents duplicates. Runs automatically.

No developers. No budget. No headaches.

Just you, n8n, and automation.

🚀 “Automate the boring stuff — focus on what matters.”

📣 CALL TO ACTION

Like this guide? Share it with your network!
Stuck? Drop a comment — I’ll help you!
Want Part 2? “Sync New Users to Mailchimp + Send Welcome Email” — let me know!

Subscribe for More Tutorials

#Firebase #n8n #GoogleSheets #NoCode #Automation #SaaS #IndieHacker #Marketing #UserGrowth #Pagination

About the Author

Written by - Passionate about coding, web development, and sharing knowledge with the Coding India community.

Join the Discussion