My OAuth Tokens Kept Expiring Every 7 Days, and the Reason Was a Dropdown Labeled 'Testing'
Three weeks into running my publishing pipeline on autopilot, it just stopped. Not with a crash -- with the exact same error I'd already spent a week debugging and fixing once before: invalid_grant: Token has been expired or revoked . Same message, same script, same working setup. I assumed I'd broken my own fix. I hadn't. This was a completely different bug wearing the same disguise, and it had…
My OAuth tokens kept expiring every seven days, despite no changes to the setup or the app's usage. The issue persisted even after fixing a different bug and verifying that the token file remained untouched. The root cause was discovered in the OAuth consent screen: the "Testing" setting in Google Cloud's Google Auth Platform restricted refresh tokens to a maximum of seven days, regardless of usage.
To resolve the problem, the Publishing status was switched from "Testing" to "In production," which allowed refresh tokens to maintain a longer lifespan. Additionally, the script was updated to catch refresh failures explicitly, providing a clearer error message and preventing silent failures. This change ensured that future OAuth-related issues would be more easily identifiable and manageable.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.