New Spotify Integration Error INVALID_CLIENT: Invalid redirect URI

Hi,
I didn’t success with spotify, i tried all URL:
http://192.168.1.XX:8123/auth/external/callback
https://192.168.xx:8123/auth/external/callback
https://xxxx.duckdns.org:8123/auth/external/callback

I checked configuration.yaml, i do specified an internal and external adresse in http:

i notice also, even if i change url in spotify setting, when launch integration, it seems that HA launch the first URL set, i change it manually to test.

What i have miss here ??

Thanks

1 Like

Where should I paste this data in node red?

because I also have the same problem as others despite different url configurations (192.168.x.y: 8180 or https)

In my case I was entering the http://192.168.1.XX:8123/auth/external/callback URL but when trying to authorize it, I noticed that the IP was getting replaced with homeassistant.local:8123/ so I went back to the developer portal and used that instead and it worked instantly.

http://homeassistant.local:8123/auth/external/callback

Might be too late to help you as you may have figured it out but adding it here as it would have helped me to read it here :smiley: so someone else may benefit from it.

6 Likes

Thanks aruffel, i will try it.

1 Like

This right here! Thank you for this!

1 Like

Thanks! Sorted my issue too

1 Like

ok - for future people like me who like kindergarden instructions…

1: in Spotify developer, put a whatever url just to know that this is a wrong one

2: go to Home Assistant, where you see the spotify integration discovered and click “configure”.
You will get an error - but your solution is in here: (you can click on that rediculously small screenshot by the way)

Find out what YOUR url is shown (because if you see this trail, there are many versions)…

And paste that back in spotify

11 Likes

Many thanks for the “instructions for dummies”, they helped me too!

1 Like

@jhqv credit goes to @lkeays

1 Like

Thank you to @aruffell for linking @jhqv I couldn’t have figured this out without either of you.

Now that it works though, what can I do with it? Especially considering I don’t have a premium subscription.

You da man! This needs to be added to the official documentation.

Agreed, this really need to be added to the official documentation. It’s been stumping me for weeks now - it wouldn’t work no matter what I put in the redirect URL - and with this little change it works perfectly.

I do not get Point(2)
HomeAssistantSpotify seems to be custom application name right?
I do not see any ‘configure’ to click from my developers dashboard.
am a newbie

Thankyou!!! This needs to be added to the official documentation!!! hours wasted time could be avoided

After several failed attempts, this is the one that worked for me. Thank you.

I give up. Tried 100 different ways.

Can I play Spotify … Yes!
Cover art, use the spotify card , nope.
Completely broken.

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/ban.py", line 82, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/components/config/config_entries.py", line 168, in get
    return await super().get(request, flow_id)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/data_entry_flow.py", line 95, in get
    result = await self._flow_mgr.async_configure(flow_id)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 277, in async_configure
    result = await self._async_handle_step(
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 359, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 303, in async_step_creation
    token = await self.flow_impl.async_resolve_external_data(self.external_data)
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 169, in async_resolve_external_data
    return await self._token_request(
  File "/srv/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/config_entry_oauth2_flow.py", line 205, in _token_request
    resp.raise_for_status()
  File "/srv/homeassistant/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://accounts.spotify.com/api/token')

Uninstalled a dozen time, reinstalled dozen times, rebooting in between even. Different URLs, Modifed/added different URLs in developer.

It is 100% broken for me.

Time to write my own I guess.

The whole “we assume you URL is this” is wrong and it causes issues in your installation config flow.

And if that means nothing to your installation … http://homeassistant.local:8123/auth/external/callback will cause an error and does not work.

If it can help help those in your situation: I never succeeded either despite all the attempts… but the option that worked for spotify is the music assistant integration.

Think this might help a few people. Seems like the spotify integration has changed the redirect URI from:

http://homeassistant:8123/auth/external/callback

to the below:
https://my.home-assistant.io/redirect/oauth

So you need to add/change the redirect URI in your Spotify application in your developer dashboard (on spotify). Now working for me!

9 Likes

This was exactly what I needed thank you!