Reject a wrong Client ID or Secret before the Spotify redirect - #74
Merged
Merged
Conversation
Home Assistant stores application credentials outside the config entry and never validates them. A typo in the Client ID or Secret sent the user to Spotify's own INVALID_CLIENT page, the browser was never redirected back, and the flow sat on the external step until it timed out. Since no config entry exists at that point there is nothing for a repair or a reauth to attach to, and reinstalling Spotcast does not bring the credentials form back because the bad pair stays in HA's store. async_step_auth now asks Spotify to validate the stored pair with a client-credentials token request before generating the authorize URL. A 400 invalid_client answer aborts the flow with a message that links to the Application credentials panel (My Home Assistant redirect) and to a new docs section on resetting them. Anything else (network error, 429, 5xx, odd payload) falls through to the normal flow so a Spotify hiccup never blocks setup. Reauth passes through the same step, so a rotated secret is covered too. The first setup screen gains a link to the reset instructions, the guide gets a dedicated "Changing or resetting the application credentials" section, and the README points at it. Fixes #73 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Sep 19, 2026
Merged
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.
Problem
Home Assistant stores application credentials outside the config entry and never validates them. A typo in the Client ID or Secret sends the user to Spotify's own
INVALID_CLIENTpage, the browser is never redirected back, and the flow sits on the external step until it times out. No config entry exists at that point, so there is nothing for a repair or a reauth to attach to, and reinstalling Spotcast does not bring the credentials form back because the bad pair stays in HA's store (#73).Fix
async_step_authnow validates the stored pair with a client-credentials token request before generating the authorize URL. A400 invalid_clientanswer aborts the flow with a newinvalid_credentialsmessage linking to the Application credentials panel (My Home Assistant redirect) and to the docs. Anything else (network error, 429, 5xx, odd payload) falls through so a Spotify hiccup never blocks setup. Reauth uses the same step, so a rotated secret is covered too.Verification
400 invalid_client; an offline session is reported as not rejected.Fixes #73
🤖 Generated with Claude Code