post: claude setup-token fixed my launchd auth and dropped my connectors - #52
Open
clarkbw wants to merge 1 commit into
Open
post: claude setup-token fixed my launchd auth and dropped my connectors#52clarkbw wants to merge 1 commit into
clarkbw wants to merge 1 commit into
Conversation
Draft for review. CLAUDE_CODE_OAUTH_TOKEN outranks the /login session in Claude Code's auth precedence, so a setup-token added to survive a launchd keychain failure silently removes every claude.ai account connector — four daily runs exited 0 and wrote their artifact while blind to email and calendar. Plus: exit code 0 is not a success criterion, and a find -newermt heartbeat that read false in-script and true by hand. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HaMaRk9UijJQMDX48EVvTk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Post: 2026-08-11-claude-setup-token-drops-claude-ai-connectors-gmail-calendar-headless-claude-p-launchd-keychain-oauth-token-precedence.md
Blog candidate #9. Draft only — date is the draft date (2026-08-11);
script/bump.py/script/publish.pybump it at merge.Title: claude setup-token fixed my launchd auth and dropped my connectors
The story
A scheduled headless
claude -pjob died on an expired keychain OAuth session. The fix — a one-yearCLAUDE_CODE_OAUTH_TOKENfromclaude setup-token, sourced from the job's shared env file — authenticates fine and silently removes every claude.ai account connector (Gmail / Calendar / Drive), because the token sits at rank 5 in Claude Code's auth precedence and/loginsits at rank 7. Four daily runs exited 0, wrote their artifact, and were blind to email and calendar. Fix: keychain session primary with the token explicitly unset, token as an announced degraded fallback; success redefined as "an artifact newer than this run's start", checked by mtime. Bonus: thefind -newermt "@$STAMP" -print -quitheartbeat that read false in-script and true by hand, replaced withls -t+stat -f %m.One thing changed from the brief
The behaviour is documented, not undocumented. I went looking for docs to caveat the claim against and found it stated twice, verbatim:
Both fetched and quoted verbatim. That makes the post stronger, not weaker — it's no longer "here's an undocumented bug", it's "here's a documented cost you'll pay by accident, and here's why nothing tells you". Only the
claude mcp listoutput is flagged as my own observation (the docs describe/mcpand/status, neverclaude mcp list), with a version note.SEO
Slug/description/tags carry:
claude setup-token,CLAUDE_CODE_OAUTH_TOKEN,claude mcp list, claude.ai connectors Gmail / Google Calendar / Google Drive, headlessclaude -p, launchd, macOS keychain, authentication precedence, "OAuth session expired and could not be refreshed",Login expired · Please run /login. Per the research sweep, the genuinely unclaimed search real estate is the conjunction — the launchd fix and the connector cost are each written up separately and nobody has connected them.Figures
connector-auth-path.svg— the mechanism: two lanes (login session vs token), the ✕ where the account-session fetch doesn't happen, model requests fine in both.four-green-runs.svg— six days of runs: one loud failure, four green runs with connectors missing.Privacy
No hostnames, no private repo names, no infra paths, no job names beyond "a daily scheduled agent job". All snippets are sanitized reconstructions (generic
reports/paths,$HOME/.agent/.env), not private file contents. Public link isnaturali-agents.Verified
python3 script/lint-liquid.py→ 35 posts clean ·bundle exec jekyll build→ clean · both SVGs present in_site/assets/img/<slug>/and both<img src="/assets/…">render · all threepost_urlrelated links resolve.Worth a check before publishing
no-timeoutand the session genuinely expired. The post deliberately doesn't relitigate it.