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

Cannot add Ytube Music to Music Assistant #3138

Open cherryocola opened 2 weeks ago

cherryocola commented 2 weeks ago

What version of Music Assistant has the issue?

2.3.2

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

2024.11.1

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

The problem

When authenticating Youtube music and saving the token generated, the following error was produced

ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)

How to reproduce

  1. Authenticate ytube music
  2. Save

Music Providers

Ytube Music

Player Providers

Google Cast

Full log output

music-assistant.log

Additional information

No response

What version of Home Assistant Core are your running

2024.10.4

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Raspberry Pi

contactnat commented 2 weeks ago

yeah mine has stopped working after yesterdays update - I have not tried to trouble shoot or reauthenticate or anything, just acknowledging that it stopped.

DarrolMusambani commented 2 weeks ago

Same here. Server: 2.4.0b4 Integration: 2024.11.1

even reverting back to 2.3.0rc2 or reauthentication didn't fix it.

OzGav commented 1 week ago

People are finding a solution is to create another brand account. https://sproutsocial.com/glossary/youtube-brand-account/

contactnat commented 1 week ago

People are finding a solution is to create another brand account. https://sproutsocial.com/glossary/youtube-brand-account/

ah that does seem to work, although now my playlists need to be moved over, bit annoying LOL, I understand YT Music is best efforts, so just happy to have it working again! thanks.

OzGav commented 1 week ago

Our best guess is YouTube is doing something deliberate to deny access.

contactnat commented 1 week ago

Our best guess is YouTube is doing something deliberate to deny access.

all the more reason to work towards not being dependent on them, and google in general - that's my home lab driver at the moment..

Dion-HA commented 1 week ago

I'm having the same issue, e.g. ERROR: [youtube+yt_access_token]...

I can't connect my Youtube (personal) account with Music Assistance any more, that was previously working.

OzGav commented 1 week ago

@Dion-HA read this issue for the workaround….

Dion-HA commented 1 week ago

@Dion-HA read this issue for the workaround….

@OzGav read what for a workaround?

I looked at the Youtube brand accounts, we should not need to create a new Youtube brand account, just to link Youtube Music with Music Assistant, it was working previously.

I also tried using my business Gmail account to link Youtube Music with Music Assistant and got this error message instead: User does not have Youtube Music Premium.

I then tried linking Spotify and that worked without any issues, but I don't use Spotify. I ony use Youtube Music Premium with my personal Gmail account.

OzGav commented 1 week ago

@Dion-HA Do you understand this is Google's doing? Please contact them with your frustrations.

cherryocola commented 1 week ago

Sigh... looks like I have to go back to ytubemediaplayer

OzGav commented 1 week ago

@cherryocola So the workaround is not working for you?

cherryocola commented 1 week ago

@cherryocola So the workaround is not working for you?

Apologies, I havent tried it I am sure it works, I just didnt want another google account. thanks.

OzGav commented 1 week ago

@cherryocola It isn't another Google account. It is a "brand" within your Google account.

cherryocola commented 1 week ago

@cherryocola It isn't another Google account. It is a "brand" within your Google account.

So I started my channel and branding but still get the error message, any ideas? thanks

OzGav commented 1 week ago

@cherryocola Not at this time. You are the first person to say they tried creating a brand account and it didn't work...

edit: Keep an eye on things as sometimes Google reverts these changes and everything just starts working again...

cherryocola commented 1 week ago

@cherryocola Not at this time. You are the first person to say they tried creating a brand account and it didn't work...

edit: Keep an eye on things as sometimes Google reverts these changes and everything just starts working again...

maybe because I always had a channel and I only added a branding? I probably need another account.

devedsmith commented 1 week ago

Mine just stopped working with the same error

zed0 commented 1 week ago

yt-dlp is having the same issue: https://github.com/yt-dlp/yt-dlp/issues/11503

Dion-HA commented 1 week ago

Creating a Youtube brand account to add Youtube Music as a Music Provider for Music Assistant fixes this issue.

I just created a Youtube brand account for my persoal Google account and can confirm that this now works and all my previous playlists, artist, etc are still available using the new Youtube brand account to authenticate with Music Assistant :)

Peyto79 commented 1 week ago

I just tried the workaround but I get the same error. The workaround seems not to work anymore. I get the same HTTP400 error with the new "brand account"

Orsonorix commented 1 week ago

Any other solutions other than brand account?

zed0 commented 1 week ago

From the yt-dlp thread it seems like the real fix is to store a cookie to use for Auth. Unfortunately this will require rewriting the music-assistant YouTube auth code and a much more complicated user flow involving extracting cookies from a browser

Pankotskiy commented 1 week ago

Linked my brand account and there is different music on it, no playlists, no library. Are there any suggestions?

EvanWasHere-zz commented 1 week ago

I already had a brand account. But I created another one to try the solution above. And I got the same error.

OzGav commented 1 week ago

It appears that OAUTH support has been removed. An alternate method of logging in is being investigated. This will take some time.

Dion-HA commented 1 week ago

My Youtube Music is still working with Music Assistant since I set in up yesterday using the Youtube Brand account work around with my existing personal Google account, I'm reluctant to remove this connection and set it up again as it's still working for me now :)

SIR-Inc commented 1 week ago

I doubt it adds any value to resolving this issue but I'm curious if anyone else is experiencing numerous Home Assistant failed login attempts from Google datacenters since the YouTube Music issue started in Music Assistant. Here is an example: Login attempt failed Login attempt or request with invalid authentication from 51.150.48.34.bc.googleusercontent.com (34.48.150.51). See the log for details.

What surprises me is that this has continued even after I removed YouTube Music as a provider in Music Assistant. Oh well.

grainsoflight commented 1 week ago

You can contact google about this and give them your thoughts here https://support.google.com/youtube/gethelp

bazsc20ne commented 1 week ago

Sigh... looks like I have to go back to ytubemediaplayer

that doesn't work for me either :(

szemod commented 1 week ago

I created the Brand account (multiple accounts, in fact), but I'm still encountering the same error message: "ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)" when I try to save the YouTube Music Provider after successfully authenticating and granting permission with the Brand account.

Zsoltt-dom commented 1 week ago

Same issue here. Adding a Brand account won't work. ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)

TheWebMachine commented 1 week ago

So, everything was working perfectly fine for me until last night when I updated the HA Integration (not the add-on). Suddenly, both MA AND my YT Music app on my phone started throwing a ton of errors. On the YTM app, it would just keep skipping through tracks as unavailable until hitting the end of the queue. During this period, I saw various errors on MA about unavailable/invalid tokens, API availability, etc.

Hours later, YTM app slowly regained the ability to start playing tracks again, albeit with some random track skips, until it finally regained full function this morning. YTM now can play music again, but even after fully removing and trying to re-add YTM to MA, I get the following errors:

WARNING: [youtube+yt_access_token] Incomplete data received in embedded initial data; re-fetching using API.
WARNING: [youtube+yt_access_token] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube+yt_access_token] HTTP Error 400: Bad Request. Retrying (1/3)...
WARNING: [youtube+yt_access_token] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube+yt_access_token] HTTP Error 400: Bad Request. Retrying (2/3)...
WARNING: [youtube+yt_access_token] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube+yt_access_token] HTTP Error 400: Bad Request. Retrying (3/3)...
WARNING: [youtube+yt_access_token] YouTube said: ERROR - Request contains an invalid argument.
ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)
2024-11-14 11:58:16.256 ERROR (MainThread) [music_assistant.webserver] Error handling message: config/providers/save: ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)

To be clear, I already have multiple brand accounts on my main account and none of them work. So, I have two theories at this time:

  1. YTM implemented some new rate limiting and MA's syncing is now hitting this limit (which is why a new brand account worked for some; because a sync on a new clean brand would not hit the rate limit on initial sync)
  2. YTM has decided to break or change some bit that our current YTM sync engine relies on; perhaps accidentally, perhaps intentionally (MA has massively gained in popularity in recent months and Google may have finally noticed the uptick in our traffic)

Let me know if there is any testing I can help perform from my end.

afs5327 commented 1 week ago

I'm not sure if it helps, or if this wouldn't work with MA, but the HA-Google-Home uses Google Authentication Tokens for access to Google accounts, and that add-on is still working for me.

There are tons of forum posts about folks having issues with using the tokens, so they can be a bit fiddly, but once I got it working for the HA-Google-Home add-on, it's been solid for months now.

feinadam commented 1 week ago

Same issue at me :(

TheWebMachine commented 1 week ago

I'm not sure if it helps, or if this wouldn't work with MA, but the HA-Google-Home uses Google Authentication Tokens for access to Google accounts, and that add-on is still working for me.

There are tons of forum posts about folks having issues with using the tokens, so they can be a bit fiddly, but once I got it working for the HA-Google-Home add-on, it's been solid for months now.

I don't think it's the tokens themselves in this case. I think the change is in how the API is parsing requests against YTM. Perhaps a slow server-side rollout across all YTM accounts, which would explain why it has seemingly affected us in waves over the last week or so. Mine worked flawlessly until last night while some have been having the issue for a week or more.

EFH52 commented 6 days ago

Brand account alternative solution failed to resolve the issue here.

mterry63 commented 6 days ago

Brand account alternative solution failed to work for me as well.

ufondu88 commented 6 days ago

Brand account failed for me too

Vergil365 commented 6 days ago

Brand account failed for me as well

mterry63 commented 6 days ago

Just for clarity for anyone that created a brand account as a solution, are you supposed to somehow authenticate with that account? I just created the brand account but authenticated with my normal account as the brand account required no kind of password or authentication settings. How would the brand account authentication work exactly?

TheWebMachine commented 6 days ago

When you sign in on Google, it should ask you which sub-account you want to use - your primary or a brand account. If it doesn't, try creating a PL on YTM under that brand account and sign in on MA again.

leolionart commented 6 days ago
image

I created a new brand account on the old account, even created a completely new google account. But it seems nothing has changed. Still ERROR 400 when Add Youtube Music

Dion-HA commented 6 days ago

I'm not sure if it helps, or if this wouldn't work with MA, but the HA-Google-Home uses Google Authentication Tokens for access to Google accounts, and that add-on is still working for me. There are tons of forum posts about folks having issues with using the tokens, so they can be a bit fiddly, but once I got it working for the HA-Google-Home add-on, it's been solid for months now.

I don't think it's the tokens themselves in this case. I think the change is in how the API is parsing requests against YTM. Perhaps a slow server-side rollout across all YTM accounts, which would explain why it has seemingly affected us in waves over the last week or so. Mine worked flawlessly until last night while some have been having the issue for a week or more.

I'm now having the same issue using the YT Brand account to authenticate with MA, e.g. ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)

TheWebMachine commented 6 days ago

I'm now having the same issue using the YT Brand account to authenticate with MA, e.g. ERROR: [youtube+yt_access_token] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)

It's almost certainly an API change and this means we'd have to wait for the maintainer of the Python library MA is depending on (yt-dlp) to find and correct accordingly. This will take time. I'm lowkey sad that every time I get used to using YTM again, it breaks again.

CappyT commented 6 days ago

Youtube "dropped" support (more like prevented misuse) for OAuth as described in yt-dlp comment here. Music assistant needs to rework the login to intercept user cookies instead, which is painful, but is the only way forward.

Yt-dlp already works with cookies.

The reason on why the workaround with brand accounts worked is that google applies changes in "waves" until is fully applied to everyone. It's unlikely that OAuth "method" will ever work again, as google needs to rollback the change

OzGav commented 6 days ago

Progress has been made. Expect more info in the next couple of days,

shaiger commented 6 days ago

The documentation page provides instructions for heading down the "cookie path", yet the UI does not provide the option to paste the cookie info. I can only take the "token path" using the UI. Is there a manual way to enter the cookie data?

OzGav commented 5 days ago

Expect more info in the next couple of days.

shaiger commented 5 days ago

Thanks for the UI update! I can play music now, though uploaded music is not working.