mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-26 07:46:00 +03:00
[GH-ISSUE #676] 400 Bad Request error when using oauth, but browser authentication works #450
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#450
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AntitrustEnthusiast on GitHub (Nov 9, 2024).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/676
Describe the bug
the
ytmusic.search()command is throwing aHTTP 400: Bad Requesterror with the messageRequest contains an invalid argument, but only when using oauth. Browser authentication works fine.Using
ytmusicapiversion 1.8.2To Reproduce
Steps to reproduce the behavior:
ytmusicapi oauthas documented in setupResult:
Additional context
I've been using it for quite a while without issue, but today it stopped working, seemingly at random. Switching to browser auth has temporarily fixed it for my workflow.
Deleting
oauth.jsonand redoing the authentication flow didn't work either.@zostay commented on GitHub (Nov 9, 2024):
I too have started getting this, though, I can't get the browser auth to work either.
@sigma67 commented on GitHub (Nov 9, 2024):
Could you try messing with the headers to see if removing some fixes it? Hard to tell what the issue is without further indication
@AntitrustEnthusiast commented on GitHub (Nov 9, 2024):
Hmm, I ran test requests using this code:
While removing one of these headers each time:
All of them except
authorizationreturned the exact same error message:Request contains an invalid argument.Here's the full error from the API, in case it helps:
Also tried removing
?alt=jsonfrom the endpoint, no change.The only one that had a different result was removing the
authenticationheader, which returned aYou must be signed in to perform this operation.error.@rafaeldrrmachado commented on GitHub (Nov 11, 2024):
Does anyone know where the oauth.json file is stored? I can't findi it to try and delete it
@srajangarg commented on GitHub (Nov 11, 2024):
same issue, commenting for visibility!
guessing its a server side change that break the api
@AntitrustEnthusiast commented on GitHub (Nov 12, 2024):
Someone in the linked spotify_to_ytmusic issue mentioned it works for them as Manager of their family plan, but not for their wife and kids (non-managers).
I am in the same situation (non-manager), is everyone else experiencing the issue also a non-manager on a family plan?
@hhh4hn commented on GitHub (Nov 12, 2024):
This seems related to what I've noticed: it's working fine for me when using oauth creds for one account that is a primary account of mine, but it does not work on another which is a "brand account" under a second account. I get
400: Bad Requeston any call using that brand account.Edit: on further testing, it seems like my 2nd account (which is under a family plan), whether I use its primary or brand account, fail with this error, so my experience supports @AntitrustEnthusiast hypothesis.
@apastel commented on GitHub (Nov 12, 2024):
My account is the manager of my family plan and I get the
400: Bad Requesterror when using oauth creds.@sabad67 commented on GitHub (Nov 12, 2024):
i am seeing this issue as a manager of a family plan.
@soreikomori commented on GitHub (Nov 12, 2024):
Same here when calling yt.get_history(). I also tried updating to no avail. Currently on ver. 1.8.2.
@sigma67 commented on GitHub (Nov 13, 2024):
I doubt this is related to family plans, likely just a coincidence.
I would suspect that something in here broke/needs to be updated due the server-side update: https://github.com/sigma67/ytmusicapi/blob/main/ytmusicapi/helpers.py
I will try comparing our requests with the current requests on the web when I find time. Unfortunately I work a full time job so it might be a few days. I certainly recognize the importance of the issue given the number of reports.
In the meantime, anyone else with the time can perform the same analysis!
@secnonsense commented on GitHub (Nov 13, 2024):
I have an individual plan and am also seeing this error. Maybe the issue is due to having multiple accounts on the plan? In my instance I use a branded account instead of my primary gmail.com account. I saw the error using my branded account, however after regenerating my oauth.json using my gmail.com account everything worked as expected.
@Batwam commented on GitHub (Nov 14, 2024):
I'm also getting this HTTP 400 error for the last few days. Glad to see I'm not alone. I tried to generate oauth.json from 2 separate accounts and both of them fail.
@parthcooks commented on GitHub (Nov 14, 2024):
it was working for me till yesterday , today even im facing this issue , sigma67 is there any fix for this?
@apastel commented on GitHub (Nov 14, 2024):
We're all well aware that the issue is happening, now it's time for the open-source community to do its thing and come together and fix it. If you scroll up and read @sigma67's message, you'll see they are busy and some suggestions about where to look in the meantime. It's probably some header or something that changed on one of the requests in the oauth flow. I tried looking at the API docs for OAuth 2.0 for TV and Limited-Input Device Applications but nothing stuck out as being different. Also tried going through the oauth flow in the browser and looking at the requests/responses to see if there's anything that looks like one of the requests in the helpers.py file, but I might just be looking in the wrong place. The properties in
oauth.jsonitself seem to match exactly what's expected according to that API document...@abetwothree commented on GitHub (Nov 15, 2024):
Seeing same issue. Tried multiple accounts and it all fails locally and on a server. However, it does work locally without an oauth.json file.
@apastel commented on GitHub (Nov 15, 2024):
People in different projects are saying that Google is removing OAuth support for YTMusic, and they are switching back to using cookies 😢 The reason it happens for some accounts and not others of course is because of A/B testing (edit: well, global rollout, technically)
https://github.com/KoljaWindeler/ytube_music_player/issues/367#issuecomment-2472397147
https://github.com/music-assistant/hass-music-assistant/issues/3138#issuecomment-2471316657
https://github.com/yt-dlp/yt-dlp/issues/11462#issuecomment-2471087887
I haven't seen anything conclusive stating this to be true, but it seems like developers of different projects are seeing the writing on the wall, which points toward bye-bye for OAuth. Let's hope that's not the case...I'm not sure how to determine if it is or not.
@jurgenweber commented on GitHub (Nov 15, 2024):
I agree, either A/B Testing or the nature of the global rollout.
removing OAuth just seems like a direct stab at disabling these sorts of integrations.
@sigma67 commented on GitHub (Nov 15, 2024):
As expected this is a widespread issue affecting all third-party oauth clients: https://github.com/yt-dlp/yt-dlp/issues/11462
Is anyone facing issues with browser-based auth also? Seems to be working ok for me
@srajangarg commented on GitHub (Nov 15, 2024):
@sigma67 confirming that browser-based auth also works for me
@luisignaciocc commented on GitHub (Nov 17, 2024):
For me, browser-based authentication doesn't work either. Using the get_history() (browseId: "FEmusic_history") on https://github.com/luisignaciocc/ytmusic-scrobbler-web/issues/11
@Batwam commented on GitHub (Nov 18, 2024):
same here, works with browser authentications, the instructions are here: https://ytmusicapi.readthedocs.io/en/stable/setup/browser.html
Is this authentication method going to have to be renewed regularly?
@sigma67 commented on GitHub (Nov 18, 2024):
Common advice to make long-lasting cookies is to create them using the browser's in-private session. This avoids accidentally messing with the session during your regular browsing activity
The cookies last quite long in my experience
@Batwam commented on GitHub (Nov 18, 2024):
that's good to know, thanks
@Hengen42 commented on GitHub (Nov 18, 2024):
I couldn't manage to get cookies in the brave browser. I keep getting a 401 error.
@Hengen42 commented on GitHub (Nov 18, 2024):
"te": "trailers\u001a"
I solved the issue by removing this code from the browser.json file. However, I've been struggling with it for hours. It was so silly.
Example: (where there was a space there was the usual "te": "trailers\u001a".)