oauth-token-doctor: A Claude Code Skill for Google OAuth Tokens That Expire After 7 Days

A small open-source skill and script for a very common Google API headache: refresh tokens that die after about 7 days. The cause is an OAuth app left in Testing status. I hit it myself on a YouTube upload pipeline, fixed it, and turned the walk-through into a reusable skill.

Open sourceClaude Code skill
Illustration of the oauth-token-doctor project
4
automated tests
0
dependencies, standard library only
1
command to diagnose a token
7 days
the expiry it explains and fixes

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

  1. 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.

  2. 02

    Name the cause

    On invalid_grant the checker prints the likely cause (an app in Testing status) and the exact fix path.

  3. 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.

  4. 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.
MIT licensed. It is a Claude Code skill: copy the skill folder from the repository into your skills directory.

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

Related case studies

Python / MCP / ffmpeg / Pillow / numpyOpen Source

versereel: Poem Videos With Original Ambient Music, as a CLI, MCP Server and Claude Skill

An open-source Python package I published to PyPI. It turns a poem or quote into a calm text-only vertical video (Shorts, Reels, TikTok) with an ambient music bed that is synthesised from scratch, so there is nothing to license. It handles Urdu Nastaliq and other right-to-left scripts, and ships as a CLI, a Python API, an MCP server and a Claude Code skill. It grew out of my own poetry Shorts channel, where the same code produced over a hundred videos.

Have a project like this in mind?

Tell me what you're building. I'll reply by email with questions or a suggested approach.