Spotify - INVALID_CLIENT: Invalid redirect URI

thanks, so i just add http://192.168.1.1:8123 into the redirect URLs and save
(Assuming that is my IP of my HAS instance)

Ive done this, but i still get same error

INVALID_CLIENT: Invalid redirect URI

I think it the redirect uri should be http://192.168.1.1:8123/api/spotify :wink:

I added /lovelace/xx to the end. worked for me :slight_smile:
xx is page/view number

You can solve this by exposing your HA installation to the internet. Dont forget to set the base_url in http section in configuration file.

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
base_url: https://your.domain

Got the above error when i comment it out. If I add the base url in http section, the spotify connection works like a charm.

1 Like

You should add https:///auth/external/callback to application setting on spotify.com

3 Likes

Donā€™t do this. There is no need to expose a HA instance to the internet to get the Spotify integration working. In the Spotify developer settings, set the redirect URI as shown. It can be a local ip address. I just (re)setup Spotify last night using this setting and it works perfectly.

image

2 Likes

This is how I solved my issue too. In spotify api dashboard, i added:

https://xxxxxxx.duckdns.org/auth/external/callback

as a redirect uri

This worked for me tooā€¦ Logged into Spotify dev account and added https://xxx.duckdns.org

Donā€™t add the port to the end.

I have the same problem.
I use hassio behind ngnix, so I donā€™t use HTTP Integration in configuration.yaml.
Into spotify Redirect URI i have set https://XXXX.duckdns.org/auth/external/callback

I try with Ip address too.

youā€™re probably missing the home-assistant port in the end
eg: http://xxx.xxx.xxx.xxx:8123/auth/external/callback

1 Like

Finally sorted it out ā€¦

Using DuckDNS

Redirect URI should be:
https://<your_sub_domain>.duckdns.org:8123/auth/external/callback

Anyone having this issue,

If you click on the authenticate and get the error ā€œinvalid-client-invalid-redirect-uriā€
if you look at the address bar you will see the address that needs to go in the Redirect URIs

Mine was ā€œhttp://192.168.xx.xx:8123/lovelace/haā€

Thanks

2 Likes

Here solved adding this to the URI in Spotify account:
http://homeassistant.local:8123/auth/external/callback

Is this old documentation? Where does it say you have to input this with /api/spotify and WHERE? In the config.yaml? or on the spotify side? This makes no sense.

FIXED!!! For everyone getting bad URI redirects, etc, this is what I just did after reading all of the articles on this.

First off - the main issue I found was that in my config.yaml, under homeassistant, I had the internal URL with an extension of /lovelace/standard/blah blah, instead of JUST http://myHAip:port/ Thatā€™s it!

Then for my spotify dev URI, follow the instructions and do http://localHAip:8123/auth/external/callback

Then the ā€œconfigureā€ button actually works and authā€™s your account.

This is what worked for me. I have HA exposed via duckdns (ie. https://xxxx.duckdns.org), and when I used the externally visible URL it did not work. However, using the internal URL did (ie. http://192.168.0.66:8123/auth/external/callback).

1 Like

Fixed the problem after noticing the ā€œinternal_urlā€ setting in configuration.yaml incorrectly was set to ā€œhttpsā€ rather that ā€œhttpā€. Changing it to ā€œhttpā€ and keeping the redirect uri in spotify pointing to ā€œā€¦auth/external/callbackā€ fix it for me!

Another try to give you a hint how to solve it:

Look at the URL of the ERRORā€¦ mine looks like this:
https://accounts.spotify.com/authorize?client_id=xxx&response_type=code&redirect_uri=https://xxx.duckdns.org:8123/api/hassio_ingress/xxxx/spotify-credentials/auth/callback&state=4exxxn&show_dialog=true&scope=

Therefore the redirect url is:
https://xxx.duckdns.org:8123/api/hassio_ingress/xxxx/spotify-credentials/auth/callback

Which works fine for me (even when I donā€™t know why the system takes this choiseā€¦). :slight_smile:

What did it for me is using http://homeassistant.local:8123/auth/external/callback instead of the IP addressā€¦Now letā€™s see if the ā€˜unavailableā€™ messages stay away.