Skip to content

fix(integrations): Google Search Console and Google Analytics still show "Connected" after the token expires - #252

Open
eryawww wants to merge 1 commit into
every-app:mainfrom
eryawww:fix/gsc-ga4-connection-status
Open

fix(integrations): Google Search Console and Google Analytics still show "Connected" after the token expires#252
eryawww wants to merge 1 commit into
every-app:mainfrom
eryawww:fix/gsc-ga4-connection-status

Conversation

@eryawww

@eryawww eryawww commented Aug 27, 2026

Copy link
Copy Markdown

Expected

Settings > Integrations should tell you when a Google connection actually stops working, not just whether you connected it once.

Current state

getGscConnection and getGa4Connection only check whether a connection row exists in the database. Once GSC or GA4 is connected, the badge reads "Connected" forever, even after Google revokes or expires the token. Nothing on that page tells you it's broken, and there's no way to reconnect from there.

The rest of the codebase already handles this correctly. GscCard and Ga4Card on the dashboard call a real report endpoint and fall back to a connect prompt when the grant is dead. listSitesForUserWithGrantStatus and listPropertiesForUserWithGrantStatus do the same live check per account. Settings > Integrations is the one place that never actually asks Google.

I hit this on a project I run: GSC returned api_error and GA4 returned ga4_reconnect_required through the MCP tools, while Integrations still showed both connections green.

Solution

Added GscService.verifyConnection and Ga4Service.verifyConnection. Each makes one live call, listSites or listProperties, against the connection's stored account. It is the same call the grant-status checks already use elsewhere. If Google rejects it, the function returns false.

Wired both into getGscConnection and getGa4Connection so the page shows the real state.

Prioritizing minimal change. 10 new tests cover the working and broken paths. Typecheck is clean.

getGscConnection/getGa4Connection reported "connected" based only on
whether a connection row existed, never re-checking the underlying
Google grant. A revoked/expired token showed as permanently "Connected"
with no way to reconnect from Settings > Integrations, even though the
same failure was already correctly detected (and surfaced a working
reconnect flow) by the dashboard's own report cards and by the
seo-geo-cron jobs calling the same connection through OpenSEO's MCP.

Adds GscService.verifyConnection / Ga4Service.verifyConnection, which
make the same one-call live probe (listSites / listProperties) the
existing per-account grant-status checks already use, scoped to the
specific stored connection. Wires both into the connection-status
server functions so Settings > Integrations now shows the real state
and lets the user reconnect directly, matching what klaussa.com's own
project is hitting right now (GSC api_error, GA4 ga4_reconnect_required).
@eryawww eryawww changed the title Fix GSC/GA4 connection status to actually validate the grant Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant