Skip to content

fix: resolve auth 429 and macOS keychain hang (#8)#28

Closed
akonan wants to merge 1 commit intosteipete:mainfrom
akonan:fix/auth-429-and-keychain-hang
Closed

fix: resolve auth 429 and macOS keychain hang (#8)#28
akonan wants to merge 1 commit intosteipete:mainfrom
akonan:fix/auth-429-and-keychain-hang

Conversation

@akonan
Copy link
Copy Markdown

@akonan akonan commented Mar 19, 2026

Fixes #8

Root causes

Three bugs were causing eightctl to always fail on macOS:

1. Wrong client_id in OAuth token endpoint

authTokenEndpoint() hardcoded client_id: "sleep-client" and client_secret: "" instead of using the configured app credentials. This returns a 400/429 from the auth API.

Fix: Use c.ClientID and c.ClientSecret (which default to the correct Android app credentials).

2. Infinite retry loop on 429/401

do() retried indefinitely on rate-limit and auth errors via recursion with no limit — causing permanent hangs.

Fix: Added doWithRetry() with a retriesLeft counter (max 3 retries).

3. macOS Keychain blocks in non-interactive contexts

The token cache used KeychainBackend as first preference, which pops a GUI auth dialog and blocks forever when running as an agent/daemon/CLI without a desktop session.

Fix: Switched token cache to FileBackend only (~/.config/eightctl/keyring/), which works headlessly.

Testing

After these fixes, eightctl status works first time:

mode  level
off   0

Three bugs causing eightctl to always fail on macOS:

1. authTokenEndpoint used hardcoded client_id 'sleep-client' and empty
   client_secret instead of the configured app credentials, causing 400/429
   on the OAuth token endpoint.

2. do() retried on 429/401 with infinite recursion — no retry limit meant
   the process would hang forever if the API kept rate-limiting.

3. Token cache defaulted to macOS Keychain which blocks waiting for GUI
   approval in non-interactive (agent/CLI) contexts. Switched to FileBackend
   only, which works headlessly.

Fixes steipete#8
@omarshahine
Copy link
Copy Markdown
Collaborator

Thanks for tackling the 429 loop and keychain hang, @akonan! Both are real problems. I've consolidated the fixes into #24, which includes bounded retries with backoff, headless keyring fallback, plus OAuth form-encoding and gzip fixes.

Closing this in favor of that combined fix. Appreciate the contribution — we'll get this released soon! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auth Issue]: Too Many Requests

2 participants