Google Drive Integration
Add Google Drive as a Layer 2 backup to your synchronization strategy. This provides a failsafe backup mechanism that complements the fast Cloudflare edge sync.Google Drive sync serves as an additional safety net. It’s slower than Cloudflare (3-5 seconds) but provides excellent long-term backup reliability.
Prerequisites
- Google account
- Google Cloud Console access
- Estudo Organizado already set up (local or deployed)
Setup Google Drive API
Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select an existing one
- Name it something like “Estudo Organizado”
Enable Drive API
- In the Cloud Console, go to APIs & Services → Library
- Search for “Google Drive API”
- Click on it and press Enable
Configure OAuth Consent Screen
- Go to APIs & Services → OAuth consent screen
- Select External user type
- Fill in:
- App name: Estudo Organizado
- User support email: Your email
- Developer contact: Your email
- Click Save and Continue
- Skip scopes (click Save and Continue)
- Add yourself as a test user
- Click Save and Continue
Create OAuth Client ID
- Go to APIs & Services → Credentials
- Click + Create Credentials → OAuth client ID
- Application type: Web application
- Name: “Estudo Organizado Web Client”
- Authorized JavaScript origins: Add your domain(s)
http://localhost:8000(for local testing)https://estudo-organizado.pages.dev(your Cloudflare URL)
- Authorized redirect URIs: Same as origins
- Click Create
Configure in Application
Enter Client ID
- Find the Google Drive section
- Paste your Client ID into the input field
- The page will reload to initialize the Google APIs
Connect to Drive
- Click the Connect button
- A Google OAuth popup will appear
- Select your Google account
- Grant permission to access Drive files
How It Works
Initialization
The Drive module loads Google’s API libraries dynamically:File Storage
Your data is stored as a single JSON file namedestudo-organizado-data.json in your Google Drive.
Sync Strategy
The system uses timestamp comparison to prevent data loss:If Drive has a newer version (e.g., from another device), you’ll be asked before overwriting local data.
Automatic Sync
Once connected, Drive automatically syncs with a 10-second debounce:Upload Process
The system uses Google Drive’s multipart upload API:UI Indicators
The app shows different status indicators:Disconnected
Gray dot - Not connected
Syncing
Yellow dot - Sync in progress
Connected
Green dot - Synced successfully
Manual Sync
You can manually trigger sync at any time:- Open Settings (⚙️)
- Find the Google Drive section
- Click Sync Now
- You want to ensure latest data is backed up
- You’re switching devices
- You’ve made important changes
Disconnecting
To disconnect Google Drive:Troubleshooting
OAuth popup blocked
OAuth popup blocked
Your browser may be blocking popups:
- Look for popup blocker icon in address bar
- Allow popups from your domain
- Try clicking Connect again
'APIs not loaded' error
'APIs not loaded' error
The Google APIs failed to initialize:
- Check your internet connection
- Verify Client ID is correct
- Reload the page
- Check browser console for errors
iOS Safari CORS errors
iOS Safari CORS errors
Mobile Safari sometimes blocks cross-site cookies:
- Go to Settings → Safari
- Disable “Prevent Cross-Site Tracking”
- Try connecting again
- Alternatively, use Cloudflare sync (works better on mobile)
Sync takes too long
Sync takes too long
Drive sync is intentionally slower (3-5 seconds) than Cloudflare:
- This is normal behavior
- Use Cloudflare sync for real-time needs
- Use Drive as backup/secondary layer
- Reduce sync frequency by working longer between syncs
Multiple devices conflict
Multiple devices conflict
If you modify data on multiple devices simultaneously:
- The app will ask which version to keep
- Choose the device with the most recent changes
- Consider using Cloudflare sync for multi-device scenarios
Limitations
- Speed: 3-5 second latency per sync operation
- Mobile OAuth: iOS Safari may have CORS issues with OAuth popups
- File Size: Large datasets (multi-MB) will sync slower
- Quota: Google Drive API has daily quota limits (unlikely to hit with normal use)
Best Practices
Use Dual Sync
Enable both Cloudflare (fast) and Drive (reliable backup):
- Cloudflare: Real-time sync (less than 150ms)
- Drive: Background backup (10s debounce)
Regular Manual Syncs
Before important sessions or switching devices:
- Click “Sync Now” in Drive settings
- Wait for confirmation
- Switch devices knowing data is fresh
Comparison with Cloudflare Sync
| Feature | Cloudflare | Google Drive |
|---|---|---|
| Speed | Less than 150ms | 3-5 seconds |
| Latency | Ultra-low | Moderate |
| Mobile | Excellent | iOS Safari issues |
| Setup | More steps | Simpler OAuth |
| Reliability | Very high | Very high |
| Use case | Real-time sync | Backup layer |
Next Steps
Cloudflare Setup
Set up ultra-fast edge sync with Cloudflare Workers
Manual Backup
Learn about local JSON export/import