New Spotify Integration Error INVALID_CLIENT: Invalid redirect URI

I have been following the new spotify integration as per https://www.home-assistant.io/integrations/spotify/

My config.yaml and I am on 0.105.1

spotify:
  client_id: !secret spotify_client_id
  client_secret: !secret spotify_client_secret

And when I go to add new integration, I log in to spotify on the page that pops up and then just get this error: INVALID_CLIENT: Invalid redirect URI

Anyone know what’s up?

2 Likes

Got it sorted, for those in the same boat as me you need to go to the developer page in Spotify and change the Redirect URI from

http://192.168.1.100:8123/api/spotify

to

http://192.168.1.100:8123/auth/external/callback

18 Likes

Worked for me. Thanks!

1 Like

theres the correct hint at the new spotify-integration site: “check the Redirect URI in the address bar” - there you can always find the correct redirect-URI, which needed to be entered in the spotify app settings:

https://accounts.spotify.com/authorize?response_type=code&client_id=c4bf7675939a499c123456e2c02e56d&redirect_uri=https://myserver/auth/external/callback&state=…&scope=user-modify-playback-state,user-read-playback-state,user-read-private

6 Likes

Thanks, its works!

I do confirm that you do not need to have your installation to be avaialble from outside and in case you use local IP (which works), there must be port number after the IP address:
http://192.168.1.nn:8123/auth/external/callback provided in the URI in Spotify Developer website. Once I have changed it it works fine !

1 Like

Worked for me too… thanks

This was a great help to me.

I use duckdns to expose my HA instance so i was assuming i needed to use the duckdns address which was not the case. When you reach the page that says Invalid redirect URI, check the address bar for the redirect_uri that is trying to be authenticated. in my case, it was my localhost ip so i added that to the spotify configuration and that fixes my issue.

4 Likes

This fixed it!! :slight_smile:

This also worked for me…

Hello, I have a different problem with the integration of Spotify…
Went to the Developers part of the Spotify website and created a Client ID and Secret. Filled these in my secrets.yaml.
But my problem is with the URI configuration.
At first i filled in: http://192.168.178.222:8123/auth/external/callback, and then i received the INVALID_CLIENT: Invalid redirect URI.
I checked the URI which is send to Spotify:
https://accounts.spotify.com/authorize?response_type=code&client_id=my-spotify-client-id&redirect_uri=http://192.168.178.222/auth/external/callback&state=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmbG93X2lkIjoiOWZjYjdkMjVkMzRmNDNmNTlkNDgwNDNiOTI4YzRkOTMifQ.wW7-IM68K3hpNUtdtM_bIlqbipBlQ2_hyfCIZIg3tYQ&scope=user-modify-playback-state,user-read-playback-state,user-read-private,playlist-read-private,playlist-read-collaborative,user-library-read,user-top-read,user-read-playback-position,user-read-recently-played,user-follow-read

Pay attention, that there is no port nr in the URI. And thats bothering me…
I changed the URI in the Developer page at Spotify also without the port nr.
The integration process finished after that, but it does not yet function…
Any help please

1 Like

Gracias! Thanks.! :grinning:

I have the same problem can’t figure out what is causing the error.
When i take the url that is behind the string i get an 404
The url fired is not reponding able to access the /auth/external/ string … bug?
http://xxxxxxxxxxxxx:8123/auth/external/callback&state=eyJ0...and so on…

Regards
Eelco

Aight! It now worked. The exicisting link in Spotify Dev was somehow wrong (a double https:// )…

I have the same problem (INVALID_CLIENT: Invalid redirect URI).

I use this adress but I doesn’t work:

https://accounts.spotify.com/authorize?response_type=code&client_id=xxxxxxxxx&redirect_uri=http://192.168.xxxx.xxx:8123/auth/external/callback&state=xxxxxx&scope=user-modify-playback-state,user-read-playback-state,user-read-private,playlist-read-private,playlist-read-collaborative,user-library-read,user-top-read,user-read-playback-position,user-read-recently-played,user-follow-read

This fixed it for me. Thanks for the info.

I use a custom domain: https://home.something.com. I put the :443 into Spotify and the URL did not have the 443 when trying to setup. Removed the port from the URL in Spotify and all worked.

I’ve fixed the problem with the solution that’s posted up her, but then I run into another error. I get send back to my own IP and that gives me " 500 Internal Server Error

Server got itself in trouble"

Anyone ever had that?

ps: the correct local link is added to the spotify app, the id/secret is correct, the redirect URI is correct in the browser

I am in the same situation as @RoelofsTom , anyone can provide some help? Thank you

So I seem to have figured it out after a bunch of searching. Here’s what I’ve done:

  1. Setup the Spotify Dashboard.
  2. Get Client ID and Secret and put them in NodeRED (+ your scopes) and press Start Authentication.
  3. Most likely the INVALID_CLIENT page will come up so copy the URL and decode it.
  4. Find the URL between redirect_uri=<link_here>&state (should look something like http://<your-ha-IP>:8123/api/hassio_ingress/<bunch-of-junk>/spotify-credentials/auth/callback)
  5. In Spotify Dashboard edit your application and put that link as the Redirect URI
  6. Press Start Authentication in NodeRED again it should bring you to the permissions page where you click AGREE
  7. It will then probably open a page with 401: Unauthorized error. Select the URL and press Enter to open it again. (Don’t F5 as that doesn’t work)
  8. You should now get spotify.authorized

After digging through the forums with different posts saying to put different redirect URIs into the URL or Spotify these are the steps that worked for me.

4 Likes

Nice writeup. I just want to add one thing that was my problem. It seems that even though it looked like Spotify was saving my details in my project I never got the green banner that said “saved” and I couldnt figure out why it wasn’t working. I went back to the projects page and I had been logged off. This time when I click saved a banner came up that said details saved or something. Just a heads up if someone else gets the same problem here.