How to Store Game Data in Google Drive Using JavaScript

I’m building a browser-based puzzle game using HTML5 Canvas and JavaScript. The game will be packaged as a Chrome extension for offline play. I want to sync player progress and game settings across different devices by storing this data in the user’s Google Drive.

The data I need to save is pretty basic - just player scores, level completion status, and some configuration options. Everything fits into a small JSON file.

I’ve looked into the Google Drive API but the OAuth setup seems really complicated. Most tutorials I found are for server-side languages or older API versions.

Can someone point me toward a straightforward method to read and write files to Google Drive from client-side JavaScript? Are there any working code examples available?

Also wondering if there are alternative approaches - maybe using Google Sheets API or Firebase instead? Would it be better to set up a simple backend with Node.js or Python to handle the Google API calls?

firebase is def the way to go here. using google drive api means dealing with that crazy oauth stuff and lots of cros issues. firebase makes auth easy and syncs across devices like a charm. plus, its offline support works great for chrome extensions!

Had this same problem 6 months ago with my card game. Started with Google Drive API but hit quota limits fast, plus weird versioning issues when people played on multiple devices. Auth tokens kept expiring at the worst times too. Switched to a hybrid setup - localStorage for quick saves, then batch uploads to a simple Express backend that talks to Google’s API. The backend just stores JSON and handles conflicts when someone saves from different devices. Takes 30 minutes to deploy on Vercel or Railway, and you skip all the client-side OAuth mess. Way more reliable than handling API calls directly from the extension, especially when the network cuts out mid-game.

Yeah, you can use Google Drive API directly in your Chrome extension. It’s not too complicated. The OAuth flow works differently than web apps - just use chrome.identity API and it handles the messy stuff. I built a text editor extension with this last year. Just set up your manifest with the right permissions and OAuth client ID. After auth, make REST calls to Drive API endpoints. For small JSON files, use simple upload. But honestly? Google Drive’s probably overkill for scores and settings. I switched to Chrome’s sync storage API for the same type of data. Way simpler and built specifically for syncing extension settings. You’ll have plenty of storage quota and it works perfectly across all your signed-in Chrome browsers.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.