Self-heal revoked Spotify refresh tokens in cmd/spotify - #342
Merged
Merged
Conversation
cmd/spotify's OAuth flow used to exit with a raw API error when the cached refresh token was revoked, requiring manual config editing to recover. FetchAccessToken now clears the stale cache and re-authorizes automatically. Also adds context/ per the /improve convention, capturing why Spotify's save/remove/transfer need a separate Web API client while everything else can stay on Hammerspoon's AppleScript-backed hs.spotify. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…transient - Cap the revoked-refresh-token recovery to one retry via an explicit isRetry parameter instead of open-ended recursion, so a persistently failing config.Delete write can't loop forever against Spotify's token endpoint. - Only treat a 400 invalid_grant response as "revoked" (safe to clear the cache and re-authorize); any other failure (5xx, rate limit, etc.) now exits without destroying an otherwise-good cached refresh token. - Route exchangeAuthorizationCode's failure path through the same log.Error-based exitOnTokenError helper as the new non-revoked failure path in exchangeRefreshToken, instead of a one-off fmt.Println. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
cmd/spotify's OAuth flow used to exit with a raw API error when the cached refresh token was revoked, requiring manual editing of ~/.dots/sys/config to recover. FetchAccessToken now detects a genuine invalid_grant, clears the stale cache, and re-authorizes automatically (capped at one retry). Other token-endpoint failures (5xx, rate limits) still exit without touching an otherwise-good cached refresh token. Adds context/ per the /improve convention, documenting why Spotify's save/remove/transfer require the Web API while everything else stays on Hammerspoon's AppleScript-backed hs.spotify.
Co-Authored-By: Claude noreply@anthropic.com