music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.39k stars 51 forks source link

Spotify provider | Login failed since 2.1.3 #2754

Closed eekamouze closed 2 months ago

eekamouze commented 3 months ago

What version of Music Assistant has the issue?

2.1.3

What version of the Home Assistant Integration have you got installed?

n/a

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

I received a notification from spotify yesterday night telling me that my password has been reseted due to abnormal activity. After changing my password today I realized that I cannot login anymore within MASS spotify provider. I did the upgrade to 2.1.3 24h ago and I suspect the abnormal activity comes from MASS. I rolled back to a previous version (2.0.7) and that fixed the problem

How to reproduce

Upgrade to 2.1.3 (latest)

Music Providers

Spotify

Player Providers

n/a

Full log output

No response

Additional information

No response

What version of Home Assistant Core are your running

2024.8.1

What type of installation are you running?

Home Assistant Container

On what type of hardware are you running?

Raspberry Pi

marcelveldt commented 3 months ago

That was a typo... of course I tried to enable. I tried it in three different browsers plus the app, so this doesnt answer my question.

I think it wont work on iOS at all - seems like iOS is actively blocking all popups (or requests for new tabs) by default. So if you pick a desktop machine it will work. Not sure if there is anything we can do about that, it feels a bit strange that they block this so hard.

marcelveldt commented 3 months ago

Found a workaround for iOS, available in b11

terierul commented 3 months ago

for me is not working . it remains in this step forever image

tried chrome and MS edge. popup enable

marcelveldt commented 3 months ago

for me is not working . it remains is this step forever tried chrome and MS edge. popup diasabled

That is because you are still on the old version. The fix we are talking about here is only available in 2.2.0 beta 11. We will push out a new stable version soon but we want to make sure everything works as expected.

In your case you still have the connect auth, so you need to open the spotify app to authenticate

marcelveldt commented 2 months ago

2.2.0 stable has landed (with the -final- new spotify auth flow) - we also released 2.3.0 beta 0 with these fixes included

robin-thoni commented 2 months ago

Just tried twice, but it didn't work.

First time, I got a blank page on the MASS callback url saying I successfully logged in, but the provider was not in the settings.

Second time, the pop-up just closed after clicking Agree on the Spotify OAuth flow. Still no music provider.

Will try again tomorrow from desktop (tried on phone).

BTW, the callback URL is the IP address with a port number. Would be really great to use the current Host instead, in case the IP:port would be behind a RP, and not directly accessible.

OzGav commented 2 months ago

Confirm you have set the REDIRECT URL as https://music-assistant.io/callback if you are using your own client id

OzGav commented 2 months ago

Solution suggested is to remove the Spotify provider. WAIT until the logs says the removal is complete. Add the provider again.

robin-thoni commented 2 months ago

Solution suggested is to remove the Spotify provider.

I forgot to say I was trying it on a test HA/MASS instance that was never logged-in to any account, so, there's no Spotify provider yet.

Anyway, I just tried it from desktop, and it worked once I pressed Save after authentication.

I have a strange HA app behavior on Android where the app just disappears from the recent apps as soon as I leave it (and also most likely gets killed). So, I could not see the Save button on mobile after the auth process.

All clear now, thanks for your awesome work guys :+1:

OzGav commented 2 months ago

@robin-thoni Good find on the app getting killed.I will add to the docs that you need to come back to MA and hit SAVE for this to work.

marcelveldt commented 2 months ago

BTW, the callback URL is the IP address with a port number. Would be really great to use the current Host instead, in case the IP:port would be behind a RP, and not directly accessible.

You don't have to worry about that, that is sorted out automatically as long as you use "https://music-assistant.io/callback" as callback/redirect URI in the spotify dev console (when using a custom client id).

marcelveldt commented 2 months ago

Anyway, I just tried it from desktop, and it worked once I pressed Save after authentication.

Yes you really need to press save for the changes to persist. The UI will also note that but I guess in your flow that was missed.

marcelveldt commented 2 months ago

Solution suggested is to remove the Spotify provider. WAIT until the logs says the removal is complete. Add the provider again.

For now that is an accepted answer but I found the root cause fr the popup to not show on existing installs (only for new additions) - I will quickly patch it and issue a 2.2.1 update.

marcelveldt commented 2 months ago

2.2.1 is now now building - should be available within now and 15 minutes

WebSpider commented 2 months ago

I just installed 2.2.1, but the callback URL doesn't function when using this as a HomeAssistant Add-On. The redirect-page at music-assistant.io.

The state parameter that's being sent to music-assistant.io/callback in my case is:

https://music-assistant.io/callback/?code=-snipped-&state=http%3A%2F%2F-ip of my HA box-%3A8097%2Fcallback%2Fnt75pbtH4Zx

I tried, and my HA box doesn't listen on port 8097. Possibly the ingress there is causing an issue?

Running HAOS 12.4 with HomeAssistant 2024.7.4

marcelveldt commented 2 months ago

I just installed 2.2.1, but the callback URL doesn't function when using this as a HomeAssistant Add-On. The redirect-page at music-assistant.io.

Yes it is but its an URL that is only available from within your network. Did you click the link from WITHIN your local network ? You cant do this from remote

WebSpider commented 2 months ago

I just installed 2.2.1, but the callback URL doesn't function when using this as a HomeAssistant Add-On. The redirect-page at music-assistant.io.

Yes it is but its an URL that is only available from within your network. Did you click the link from WITHIN your local network ? You cant do this from remote

Thanks for the tip. Apparently I had a VPN running. Stopping that VPN and retrying made it work like a charm!

Someguitarist commented 2 months ago

I just wanted to say thank you. I updated to the newest stable version and it was incredibly easy. Just clicked Authenticate, clicked I agree, and it worked. So, so much easier than it was before!

Thanks again!

marcelveldt commented 2 months ago

Thanks for the tip. Apparently I had a VPN running. Stopping that VPN and retrying made it work like a charm!

Ah yeah, that is a good one for the documentation perhaps. Make sure you have no VPN running. The redirect URL will really only work from within your local network because MA is by default a local-network only service. We tried making the redirect work with ingress but the url was too long and it didnt accept it.

dunxd commented 2 months ago

I set this up a couple of weeks ago and the redirect URI to use then when setting up a client id in developer.spotify.com was the internal URI for my Music Assistant. It worked fine till recently.

Now it needs to be https://music-assistant.io/callback. You can't use the Spotify Developer app that worked before without changing the Redirect URI. Or just create a new app. This change should be highlighted in the documentation as a change since anyone that set this up already might not notice the change.

wallzero commented 2 months ago

I can sign in and see the popup redirect page but nothing happens after that

OzGav commented 2 months ago

You should not post to closed issues as we may not see it and you have provided insufficient information,

what server version are you on? Do you see the Spotify page to agree to the connection to MA? Are you trying to connect by using a device on the same subnet with out using a VPN, not behind a firewall or reverse proxy or anything similar

wallzero commented 2 months ago

I started with 2.2.2 and also tried 2.3.0b6.

I do see the Spotify page and am using my own client ID.

I was using MusicAssistant in a Docker config behind Traefik. It seems I can't configure the base url? I can't even authenticate with Home Assistant - it tries redirecting to the internal Docker IP.

OzGav commented 2 months ago

Probably not going to be able to help then as this sounds like a problem with your setup. Have you set the redirect URL correctly in the Spotify dashboard? Otherwise you will have to connect a device to the same subnet as MA so avoid Traefik during this setup.

wallzero commented 2 months ago

I set the redirect url to https://music-assistant.io/callback/. After I sign in to Spotify and am redirected to that page I see this:

image

But am not taken any further. I don't see any console errors at https://music-assistant.io/callback/.

I managed to connect to Home Assistant using an authentication token and Music Assistant is able to see my Snapcast server just fine. I don't think using Home Assistant with a reverse proxy like Traefik is that exotic.

Is there a way to set the base url?

image

Another option could be to manually input the code from the redirect url.

EDIT:

I found how to change the base url. I was looking for a docker environment variable but it can be changed in the interface settings. 🤦

I then tried Chrome instead of Firefox. Firefox was not properly redirecting.

And now everything seems to be working.