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.32k stars 48 forks source link

Spotify provider problem. #2758

Closed boris19 closed 1 month ago

boris19 commented 1 month ago

What version of Music Assistant has the issue?

2.1.4

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

2024.8.0

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

The problem

Hello, When I try to add a Spotify provider, it only shows me an authentication button with no option to enter login details. When we press the authentication button, it displays the loading wheel and doesn't load anything. If I try YouTube, when it clicks there it works and opens a new window.

How to reproduce

  1. Settings
  2. Add provider Spotify
  3. Push autentificate Burton

Music Providers

Spotify

Player Providers

Snapcast

Full log output

music-assistant.log

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 OS

On what type of hardware are you running?

Windows

OzGav commented 1 month ago

Follow the instructions on the screen or look at the updated docs https://music-assistant.io/music-providers/spotify/

boris19 commented 1 month ago

I have Home Assistant as VM, and proxy reverse on Apache. So I have to open Home Assistant via ip address ? Https only works for me through Apache.

simonhoffmann commented 1 month ago

Music Assistant needs to be on the same layer 2 network as any other device with an official spotify app. While the wheel spins, open the Spotify app on the other device and select "MUSIC_ASSISTANT" as a speaker. Music assistant will then be authenticated.

It does not matter if you access the Web UI of Music Assistant via IP or reverse proxy.

boris19 commented 1 month ago

Thank you for your advice. I managed to add Spotify. One more question please, how do I set up a new app in Spotify, especially the redirect link(uri), and do I need to set up a web api ? In order to get the correct clientid. Uri should be: http://ipadressMA:8095 ? Thank you.

OzGav commented 1 month ago

@boris19 None of those settings are important. I just set the redirect URI to https://www.spotify.com

simonhoffmann commented 1 month ago

Thank you for your advice. I managed to add Spotify. One more question please, how do I set up a new app in Spotify, especially the redirect link(uri), and do I need to set up a web api ? In order to get the correct clientid. Uri should be: http://ipadressMA:8095 ? Thank you.

you can use the official HA documentation for that: https://www.home-assistant.io/integrations/spotify/ However, os stated by OzGav, for Music Assistant the redirect URL does not matter. For the native integration it does tho.

robin-thoni commented 1 month ago

Music Assistant needs to be on the same layer 2 network as any other device with an official spotify app.

That's not cool :/ Can't we just go w/ a Client ID + Secret OAuth2 code flow ?

erkr commented 1 month ago

@robin-thoni MA uses Librespot. That library is still broken and can’t handle OAuth (yet). This solution is a great fix for the majority, but pity enough not for all. We know. @marcelveldt really spent hours to get it working again while waiting on Librespot for a fix

robin-thoni commented 1 month ago

Gotcha, that makes sense. THanks for your work ;)

Someguitarist commented 1 month ago

Just to double check, since it needs to be on the same layer 2 network, does this not work if you're using it in docker-compose? I've tried just about everything I can think of to get the MUSIC ASSISTANT player to pop up on every device I've got on the same wifi, with no luck. :(

OzGav commented 1 month ago

It should do unless there is something stopping the mdns discovery

Someguitarist commented 1 month ago

I'm not sure. Music Assistant is running on a headless PC. On my desktop, my phone, and my fiance's phone on Spotify I can't see it. Any other ideas for things I can change or do to make it discoverable?

marcelveldt commented 1 month ago

I'm not sure. Music Assistant is running on a headless PC. On my desktop, my phone, and my fiance's phone on Spotify I can't see it. Any other ideas for things I can change or do to make it discoverable?

Make sure it uses host networking or bridge/macvlan. Which is a requirement anyway to run MA, not only for this spotify auth discovery to work.

OzGav commented 1 month ago

Do you have host networking and privileged mode on the container?

Someguitarist commented 1 month ago

Yeah, it's using host and privileged mode. It worked great for like a week until the Librespot library issue, then it worked great for a day or two, and now I've got this issue and just can't re-add it. :/

Seems like the way to add it is good idea in theory, I just can't get it to appear in Spotify. I wonder if I got a monitor and keyboard on server if I could see it but it's just a terminal Ubuntu server with no GUI.

I know I asked in this in the other thread, but it's weird to me that Spotify will still work as a regular integration into Home Assistant using ClientIDs even with the Librespot issues. I really, really like Music Assistant UI and how it ties everything together, but I really only use Spotify and some speakers so I'm at like 30% uptime here since I started trying to use Music Assistant.

I know it's bad timing on my part with the Spotify issues, but it looks like I can just call Spotify to certain speakers through Home Assistant, which is likely what I'll do now since that just works.

I also want to add that this is a super, super cool free project, and I do really appreciate all the work ya'll put in here! I'll probably try this again in a few months once all the kinks and Spotify shenanigans are all worked out!

OzGav commented 1 month ago

@Someguitarist There is something blocking the mdns traffic then. I am deleting and re-adding Spotify accounts often at the moment doing testing and it works 100% of the time and is immediate. edit: But Im not using docker

Someguitarist commented 1 month ago

Yeah, it could be docker but at this point I'm able to run the normal Spotify integration with ClientID through my speakers with Home Assistant directly, so I'm just going to do that instead of chasing this down.

Thanks though! What's weird is the regular login method was working for me with Music Assistant just a few days ago, after the initial Librespot break. Hopefully we can go back to that method eventually, or one day support both.

OzGav commented 1 month ago

Unlikely as Spotify has removed the option of password login.

Could it be the HA integration causing issues. You could try disabling that and see if it makes any difference.

Someguitarist commented 1 month ago

I removed the integration and tried it again with no luck. If password login can't be done, could Spotify ClientID be used eventually?

I've tried just about everything I can think of now and I'm all out of ideas. Got any other ideas to make it appear? Also, is anyone else in this thread using docker other than me?

If I get some free time, I can take it out of Docker and see if it works and at least identify if that's the culprit.

Edit: Shoot, looks like it's just a HA Addon and docker? I'm somewhat computer savy but not super Linux savy, is there a way to run it outside of docker to test? I do 100% have privileged and network mode host set in the compose and on the container.

Someguitarist commented 1 month ago

EDIT: Sorry, figured it out. Had to disable UFW! Doh. Then it popped right up, authenticated with Spotify, then re-enabled UFW. Rebooted and tested and it seems like it's working. Thanks!

marcelveldt commented 1 month ago

I have some good news. I managed to get librespot compatible with the PKCE oauth flow. This means that we (finally) can have a true oauth login flow for our Spotify provider and when we need to playback we can just use the retrieved token from that flow for librespot as well.

For anyone now struggling with authentication (because it relies on librespot) that will be fixed. I am going to release a beta now with these changes so people can give it a try.

OzGav commented 1 month ago

As everyone in this thread has has their issue resolved and there is another issue report to capture further questions…closing.

OzGav commented 1 month ago

@boris19 @simonhoffmann FYI in the next update to MA it will now be required to set the REDIRECT UI to https://music-assistant.io/callback

andreclemente commented 1 month ago

Still not working for me, maybe we need add the "Bind Interface" option to the advanced settings of Spotify Music Provider?

OzGav commented 1 month ago

You are posting in closed issue but what server version and what is actually the problem. The latest beta is working fine for others

andreclemente commented 1 month ago

You're right, the latest beta version is working. Thank you.