Spotify Config

Thank you to @happyleavesaoc for this.

Configured as it says in the Spotify components web page and when this pops up.

I select the link and it gives back on a web browser.

INVALID_CLIENT: Invalid redirect URI

I have filled in the URL redirect with https://my_ip_address/api/spotify

(and i did save it after)

my_ip_address is the one i use to link to HA.

Update
Looked at the URL of the INVALID_CLIENT: Invalid redirect URI
and it gives my local ip address

redirect_uri=https%3A%2F%2F192.168.1.22

When i type into a new browser https://192.168.1.22 i get NOT SECURE.

3 Likes

Im having the same issues

Add your local IP in the Spotify Redirect URI:

http://192.168.10.80:8123/api/spotify

Worked fine for me.

/Ola

1 Like

Nope still gives the INVALID_CLIENT:

&response_type=code&redirect_uri=https%3A%2F%2F192.168.1.22%3A8123%2Fapi%2Fspotify&scope=user-modify-playback-state+user-read-playback-state

Dont no why its got https:// in the feedback because i put in the redirect URL http://192.168.1.22:8123/api/spotify.

I am using a secure connection to my HA letsencrypt.

I just had same error but on checking the spotify app page I can see when I copy pasted my local address it did a double http://http://xxx and after fixing it worked - remember to save.

For me it worked with Chrome, but not with Safari.

It seems that all of you do not have a secure connection to your HA. ie: > https://xxx.duckdns.org you use http://192.168.x.x:8123/api/spotify

I have and i have tried
http://192.168.1.22:8123/api/spotify
https://192.168.1.22:8123/api/spotify?api_password=xxxxxx
https://xxx.duck.net/api/spotify
https://xxx.duck.net/api/spotify?api_password=xxxxxx

And I did save after everyone.

1 Like

In my case i forgot the port.
I used http://192.168.xxx.xxx/api/spotify which did not work.
After adding the port such as
http://192.168.xxx.xxx:8123/api/spotify it works perfect, also with Safari.

I have a secure connection and the following worked for me:

https://192.168.x.x:8123/api/spotify

I use https://mydomain:8123/api/spotify and it works.

Mydomain maps to the local ip when inside the lan, and I also have a valid letsencrypt certificate for that address when inside (and outside).

I can get to the Spotify login page, but when I click Login I get “500 internal error”

So close!

Any error in your log?

Does this help?

BTW, I’m running HA through Docker is that matters.

17-04-22 10:38:06 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/usr/local/lib/python3.5/site-packages/aiohttp/web_protocol.py”, line 417, in start
resp = yield from self._request_handler(request)
File “/usr/local/lib/python3.5/site-packages/aiohttp/web.py”, line 289, in _handle
resp = yield from handler(request)
File “/usr/local/lib/python3.5/asyncio/coroutines.py”, line 213, in coro
res = yield from res
File “/usr/local/lib/python3.5/asyncio/coroutines.py”, line 213, in coro
res = yield from res
File “/usr/src/app/homeassistant/components/http/ban.py”, line 58, in ban_middleware_handler
return (yield from handler(request))
File “/usr/src/app/homeassistant/components/http/init.py”, line 422, in handle
result = handler(request, **request.match_info)
File “/usr/src/app/homeassistant/components/media_player/spotify.py”, line 115, in get
self.oauth.get_access_token(request.GET[‘code’])
File “/usr/local/lib/python3.5/site-packages/spotipy/oauth2.py”, line 218, in get_access_token
raise SpotifyOauthError(response.reason)
spotipy.oauth2.SpotifyOauthError: Bad Request

1 Like

I have the exact same issue, but I run a “normal” install

Well managed to get it working.Its a bit extreme.

Deleted the folders. \deps\spotipy and \deps\spotipy-2.4.4-py3.4.egg-info.

Then reinstalled the last HA sudo pip3 install homeassistant==0.42.4
Rebooted
pip3 install --upgrade homeassistant

Selected the Spotify config and it went to a web page downloaded a file
but the file had nothing in it.

Went back to Chrome Downloads and looked at the file download and selected the https:// part and it worked.

I used https://xxxx.duck.net:8123/api/spotify

I am aswell just getting an empty file called “spotify” to download from the spotify API page…

I don’t get this part of your solution

“Went back to Chrome Downloads and looked at the file download and selected the https:// part and it worked.”

Could you explain what you did in detail?

Thanks in advance

TW

Select Chrome Download in the Chrome App

Click on the https:

I am getting the same error, i don’t have my homeassistant open to the internet and only use it from a local ip, are you the same? have you found a solution for this error?

I’m using Let’s Encrypt to access my HA install over the internet with .IO domain.

Still no luck.

I changed my base_url under http: to get it to work, otherwise it would just use my IP which spotify didn’t like.

2 Likes