Getting 400 BadRequest "Request contains an invalid argument" from almost every getX method
Description:
When executing the Innertube.getHistory method the request fails with a 400 status code.
It was working without any problems for a number of clients about 8 hours ago.
Update:
Getting the same error almost every getX function
Steps to reproduce:
- Initialize Innertube client
- Try to fetch watch hisroty data using
getHistory()
...
this.#sessionClient = await Innertube.create({
...options,
timezone: LOCAL_TIMEZONE,
lang: "en",
cache: new UniversalCache(true, getCacheDir(sessionId))
});
...
const history = await this.#sessionClient?.getHistory();
Failure Logs:
InnertubeError: Request to https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json failed with status 400
at HTTPClient.fetch (/opt/youtube-client/node_modules/youtubei.js/src/utils/HTTPClient.ts:162:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Actions.execute (/opt/youtube-client/node_modules/youtubei.js/src/core/Actions.ts:166:22)
at Innertube.getHistory (/opt/youtube-client/node_modules/youtubei.js/src/Innertube.ts:339:22)
{
info: '{\n' +
' "error": {\n' +
' "code": 400,\n' +
' "message": "Request contains an invalid argument.",\n' +
' "errors": [\n' +
' {\n' +
' "message": "Request contains an invalid argument.",\n' +
' "domain": "global",\n' +
' "reason": "badRequest"\n' +
' }\n' +
' ],\n' +
' "status": "INVALID_ARGUMENT"\n' +
' }\n' +
'}\n',
date: 2025-03-08T03:12:10.115Z,
version: '13.1.0'
}
Additional Context:
- Using a verified Google OAuth Platform client with the scopes:
- auth/youtube
- auth/youtube.force-ssl
- auth/youtube-paid-content
- Tried YoutubeTv client as well.
Environment:
- YouTube.js version: 13.1.0
- Node.js version: v20.12.2
- Operating System: Ubuntu 22.04
Expected behavior:
- Should return history data.
- Should work similarly to YouTube's web interface.
Current behavior:
Returns error 400 (Bad Request):
InnertubeError: Request to https://www.youtube.com/youtubei/v1/browse?prettyPrint=false&alt=json failed with status 400
at HTTPClient.fetch (/opt/youtube-client/node_modules/youtubei.js/src/utils/HTTPClient.ts:162:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at Actions.execute (/opt/youtube-client/node_modules/youtubei.js/src/core/Actions.ts:166:22)
at Innertube.getHistory (/opt/youtube-client/node_modules/youtubei.js/src/Innertube.ts:339:22)
{
info: '{\n' +
' "error": {\n' +
' "code": 400,\n' +
' "message": "Request contains an invalid argument.",\n' +
' "errors": [\n' +
' {\n' +
' "message": "Request contains an invalid argument.",\n' +
' "domain": "global",\n' +
' "reason": "badRequest"\n' +
' }\n' +
' ],\n' +
' "status": "INVALID_ARGUMENT"\n' +
' }\n' +
'}\n',
date: 2025-03-08T03:12:10.115Z,
version: '13.1.0'
}
Version
13.1.0
Anything else?
No
Checklist:
- [x] I am running the latest version.
- [x] I checked the documentation and found no answer.
- [x] I have searched the existing issues and made sure this is not a duplicate.
- [x] I have provided sufficient information.
I'm having the same issue. I tried logging in with a different account and a different device, but it's still the same. Maybe YouTube updated their API
Same problem here with getFeed - was also working yesterday.
edit: I am using custom google oAuth
i have the same probles calling getLibrary
I'ts happening on almost every getX method.
BTW I also tried this with the standard Youtube TV client as well.
await innertube.getBasicInfo('oAA9nCqNfR4');
await innertube.getChannel('UCUQo7nzH1sXVpzL92VesANw');
await innertube.getGuide();
await innertube.getLibrary();
await innertube.getNotifications();
await innertube.getUnseenNotificationsCount();
await innertube.getTrending();
Logs:
RESPONSE: 400, TARGET_ENDPOINT: player, BODY: {"videoId":"oAA9nCqNfR4","racyCheckOk":false,"contentCheckOk":false,"playbackContext":{"contentPlaybackContext":{"vis":0,"splay":false,"lactMilliseconds":"-1","signatureTimestamp":20152}}}
---------------------------------------------------
RESPONSE: 400, TARGET_ENDPOINT: browse, BODY: {"browseId":"UCUQo7nzH1sXVpzL92VesANw"}
---------------------------------------------------
RESPONSE: 400, TARGET_ENDPOINT: /guide, BODY: {}
---------------------------------------------------
RESPONSE: 400, TARGET_ENDPOINT: browse, BODY: {"browseId":"FElibrary"}
---------------------------------------------------
RESPONSE: 400, TARGET_ENDPOINT: /notification/get_notification_menu, BODY: {"notificationsMenuRequestType":"NOTIFICATIONS_MENU_REQUEST_TYPE_INBOX"}
---------------------------------------------------
RESPONSE: 400, TARGET_ENDPOINT: /notification/get_unseen_count, BODY: {}
---------------------------------------------------
RESPONSE: 400, TARGET_ENDPOINT: browse, BODY: {"browseId":"FEtrending"}
I have encountered the same issue. Neither the custom OAuth nor YouTube TV works, but using cookies directly seems to be effective. Does anyone have a better solution?
I have encountered the same issue. Neither the custom OAuth nor YouTube TV works, but using cookies directly seems to be effective. Does anyone have a better solution?
I used OAuth and it's still not work too.
Folks, I'm a bit confused; is this happening only when using OAuth? If so, I'm afraid YouTube might have removed the ability to use OAuth with the WEB client altogether.
For now, use cookies or wait for #872.
Hi @LuanRT, thanks for the comment. Unfortunately, #872 doesn’t resolve this issue either. The PR is quite heavy and includes some out-of-context implementations. To be sure, I tested the getHistory method with all available client types.
Here are the #872 output for the getHistory method:
ClientType: WEB - Error: 400
ClientType: MWEB - Error: 400
ClientType: WEB_KIDS - Error: 401
ClientType: WEB_REMIX - Error: 404
ClientType: iOS - Error: 404
ClientType: ANDROID - Error: 404
ClientType: ANDROID_MUSIC - Error: 404
ClientType: ANDROID_CREATOR - Error: 404
ClientType: TVHTML5 - Error: 404
ClientType: TVHTML5_SIMPLY_EMBEDDED_PLAYER - Error: 404
ClientType: WEB_EMBEDDED_PLAYER - Error: 400
ClientType: WEB_CREATOR - Error: 404
I tried this with the default "YouTube on TV" app and a custom OAuth app as well.
I'm not very familiar with the Innertube API and its internals. If I'm missing something or if you have any guidance or directions, please let me know. I'll do my best to participate in finding a solution.
Ah, now I get it! I need to use the innertube.tv property and implement a getHistory method within that namespace.
@koraybilgi - were you able to make progress on this?
Hey @koraybilgi @a7medkamel did you figure out how to use it! It’s giving 400 on all get requests, it’s strange. I tried with react native, there it gives even worse errors. All i want is to create a youtube-skin application
No.. and hitting dead ends with the TV client as well