Fixed Google OAuth Hell and Added One-Click Disconnect
Had one of those satisfying debugging sessions today where everything finally clicks into place. Been wrestling with Google OAuth integration for HoneyBun, and today I managed to squash a bunch of annoying issues that were blocking users.
The OAuth Nightmare is Over (Mostly)
Started the day by setting up Cloudflare MCP for Claude Code - pretty smooth once you get the OAuth flow working in the browser. But the real win was finally fixing that redirect_uri_mismatch error that's been haunting me. Turns out I just needed to add hb-provision.andrew-833.workers.dev/gbp/callback to the Google Cloud Console. Sometimes it's the simple things that trip you up.
The bigger issue was in my buildClientSummary function. I had this requirement for locationName that was preventing integrations.gbp from ever being true. Removed that and suddenly everything started working as expected.
One Button to Rule Them All
Implemented something I'm pretty excited about - auto-discovery for GA4 and Google Search Console during the OAuth callback. Now when users hit that connect button, it automatically links up Google Business Profile, GA4, and GSC in one go. No more multi-step setup process.
I also added a proper disconnect endpoint (POST /google/disconnect/:clientId) that completely clears all Google data, plus a disconnect button in the dashboard that's always visible alongside the re-authorize option. Users were asking for an easy way to reset their connections, and now they have it.
The Little Things
Fixed an annoying bug where GSC selections weren't persisting. The panel wasn't re-rendering after saveGoogleConnection, so users would make their selection and it would just disappear. Simple fix but made a huge difference in user experience.
Made some architectural decisions that should make things more maintainable going forward:
- Frontend now checks
client.integrations.gbpfrom the index rather thanclient.gbpdirectly - Auto-discovery picks the first GA4 property and first GSC site if there's no domain match
- Disconnect completely wipes both
gbpandanalyticsfields
Still Some Rough Edges
Not everything is perfect yet. There's still an issue with GSC selection not staying green that a user reported after my latest deploy. And I'm seeing some "Failed to list GA4 accounts" errors - might be an Analytics Admin API permissions thing or users not having the right access levels.
Also discovered users need to do a hard refresh (Cmd+Shift+R) after disconnecting to clear their browser cache. Not ideal, but documenting it for now.
What's Next
I've got an uncommitted dashboard fix sitting in hb-operator-dashboard-v2.html that needs to be pushed. Priority is debugging why saveGoogleConnection might be failing silently and investigating those GA4 account listing errors.
Despite the remaining issues, today felt like a big step forward. OAuth flows are never fun to debug, but when they finally work, everything else becomes so much smoother for users.