The challenge
A scheduled upload job on a server silently stopped authenticating every week. The error, invalid_grant, says little, and the Publish app button in Google Cloud stays disabled until several branding fields are filled in.
The fix is a handful of clicks, but nothing in the console connects the symptom to the cause.
How I approached it
- 01
Diagnose without leaking secrets
A checker reads the token file locally, reports scopes, whether a refresh token exists and whether the access token has expired, and with a flag makes one refresh call. It never prints secrets, and a test enforces that.
- 02
Name the cause
On invalid_grant the checker prints the likely cause (an app in Testing status) and the exact fix path.
- 03
A skill, not just a script
The skill walks an assistant through publishing the app, including the free way to host the home page and privacy policy that Google requires, re-authorizing once, and copying the token to a server.
- 04
Tested where it counts
The analysis is a pure function, covered by tests for healthy, missing-refresh-token and expired tokens.
Deliberate trade-offs
- Google renames console menus from time to time, so the click path may drift.
- It guides the console steps but does not automate them, because publishing an app needs the owner's own sign-in.
- Unverified apps in production still show a warning screen and have a 100 user lifetime cap, which is fine for a personal tool.
What I built
- Diagnosed the real weekly token failure on a production upload pipeline and fixed it by publishing the OAuth app.
- Wrote the checker and tests, and verified it against a live refresh token.
- Wrote the skill from the steps that actually worked, including the Branding fields the Publish button needs.
What this project demonstrates
- Debugging an unclear production auth failure to its root cause
- Turning a fix into reusable documentation and tooling
- Careful handling of secrets in diagnostic tools

