Issue with Spotify Integration in Home Assistant: Stuck in Redirection Loop

Disclaimer: I tried to solve this issue with ChatGPT - sadly it wasn’t providing useful solutions. It helped me tho to write down my issue.

Hello everyone,

I’m currently facing a frustrating issue with the Spotify Integration in Home Assistant. The main problem is that I’m stuck in a redirection loop where Home Assistant tries to redirect me to an external website for authentication, but I entered the wrong data during the setup, so I can’t proceed. Here’s what’s happening:

The Issue:

  1. Redirection Loop:
  • I started the process to integrate Spotify into Home Assistant, but during the authentication phase, I entered the wrong data (incorrect API credentials).
  • Since then, Home Assistant keeps trying to redirect me to the authentication page, but it always leads to the wrong page, and I can’t move forward.
  • I get stuck at this redirection, and there’s no way to go back or stop the process from within the UI.
  1. Unable to Cancel or Go Back:
  • The UI doesn’t give me an option to cancel or backtrack from the redirection process. Every time I refresh or try to log out and back in, I end up in the same loop.
  1. This is the step I am stuck on. From there on it redirects me to an invalid link
    Screenshot 2025-01-29 at 20.15.01

What I’ve Tried So Far:

  1. Attempting to Remove Spotify via the UI:
  • I tried to remove the integration by going to Settings > Integrations, finding the Spotify integration, and selecting “Remove.” However, the removal process never completes because of the redirection issue mentioned above.
  1. Home Assistant CLI:
  • I also attempted to remove the integration using the CLI with the following command:

    ha integration remove spotify
    

    But I received an error:

    Error: unknown command "integration" for "ha"
    

    This command didn’t work, and it seems like the CLI doesn’t support this type of operation.

  1. CLI with ha core config_entries remove:
  • I tried to run:

    ha core config_entries remove 01JGRZZTCN43FF1R6FX0QEE4Z6
    

    But I got the following message:

    Error: unknown command "integration" for "ha"
    

This indicates that the command is not recognized, and I’m still unable to remove the integration.

  1. Unable to Fully Remove Integration:
  • Despite all of these attempts, I cannot fully remove Spotify from Home Assistant, and I continue to be stuck in this redirection loop.
  1. Manual Removal via File System:
  • ChatGPT suggested to go into the Home Assistant file system, specifically the core.config_entries file, and looked for entries related to Spotify. I found the config_entry_id
  • However, it told me to delete everything related to Spotify from this document.
    That would have been dozens of lines and I wasn’t sure where to start and where to end. As the suggestions from ChatGPT didn’t work up to this point, I wasn’t brave enough try to delete something I wasn’t sure about.

What I Need Help With:

  • How can I stop the redirection loop and either cancel the Spotify setup or reset it to try again?
  • Is there a way to completely remove the Spotify integration through the CLI or by editing the configuration files correctly? If so, how?
  • Has anyone encountered this issue and found a solution?

I would greatly appreciate any help or advice!

You might try going to the Application Credentials settings (under Settings \ Devices, click on 3 vertical dots menu in upper right and select Application Credentials) and see if it created any oauth2 application credentials related to spotify. If so, delete them.

You might also open the Spotify Web Player and logout of Spotify. That might at least force you into a logon screen the next time you try.

Hope it helps!

Dear god! Thank you so much.

I literally tried for hours. That was so easy actually.

1 Like

@bertoldini
Glad you got it sorted!

If it helps, here are the instructions that I use for my SpotifyPlus integration, which is a direct replacement for the HA Spotify integration (more features, search Spotify, sonos / chromecast device support, etc). I also have the SpotifyPlus Card UI, which is a front-end UI for the SpotifyPlus integration.

Check them out if you get a chance - they can run side-by-side with the HA Spotify integration, so if you wanna compare features.

Hope it helps!

Just implemented your integration and card as well.
It really is so much better.

Thanks a lot!

1 Like