Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 400 BadRequest "Request contains an invalid argument" from almost every getX method #916

Open
4 tasks done
koraybilgi opened this issue Mar 8, 2025 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@koraybilgi
Copy link

koraybilgi commented Mar 8, 2025

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:

  1. Initialize Innertube client
  2. 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:

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@farhaanaliii
Copy link

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

@a7medkamel
Copy link

a7medkamel commented Mar 8, 2025

Same problem here with getFeed - was also working yesterday.

edit: I am using custom google oAuth

@yestoall
Copy link

yestoall commented Mar 9, 2025

i have the same probles calling getLibrary

@koraybilgi
Copy link
Author

koraybilgi commented Mar 9, 2025

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"}

@koraybilgi koraybilgi changed the title Getting 400 BadRequest "Request contains an invalid argument" from getHistory Getting 400 BadRequest "Request contains an invalid argument" from almost every getX method Mar 9, 2025
@1162064779
Copy link

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?

@LuanRT LuanRT added bug Something isn't working help wanted Extra attention is needed labels Mar 10, 2025
@RikiNozomu
Copy link

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.

@LuanRT
Copy link
Owner

LuanRT commented Mar 10, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants