yt-dlp: [Youtube] HTTP Error 400 Bad Request using Oauth, but cookies work

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Region

USA

Provide a description that is worded well enough to be understood

When using oauth for authentication Youtube is returning a 400 bad request. Using the same command as either anonymous or with browser cookies (for the same account) works without any error. I am subscribed to YouTube Music (family plan) and YouTube Premium. I would like to use my account for the higher quality steams.

I’ve tried multiple different videos from both Youtube and Youtube music. I don’t have any other issues using web browsers and/or mobile devices.

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['-vU', '--username=PRIVATE', '--password=', '--list-formats', 'https://music.youtube.com/watch?v=dQw4w9WgXcQ']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.11.04 from yt-dlp/yt-dlp [197d0b03b] (pip)
[debug] Python 3.11.2 (CPython x86_64 64bit) - Linux-6.1.0-25-amd64-x86_64-with-glibc2.36 (OpenSSL 3.0.14 4 Jun 2024, glibc 2.36)
[debug] exe versions: ffmpeg 5.1.6-0 (setts), ffprobe 5.1.6-0
[debug] Optional libraries: secretstorage-3.3.3, sqlite3-3.40.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1838 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.11.04 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.11.04 from yt-dlp/yt-dlp)
[debug] Loading youtube.oauth_refresh_token_default from cache
[youtube] oauth: Refreshing access token
[debug] [youtube] oauth: Logged in using profile "default"
[youtube] Extracting URL: https://music.youtube.com/watch?v=dQw4w9WgXcQ
[youtube] dQw4w9WgXcQ: Downloading webpage
[youtube] dQw4w9WgXcQ: Downloading ios player API JSON
[youtube] dQw4w9WgXcQ: Downloading mweb player API JSON
[youtube] dQw4w9WgXcQ: Downloading ios music player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (1/3)...
[youtube] dQw4w9WgXcQ: Downloading ios music player API JSON
HTTP Error 400: Bad Request
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (2/3)...
[youtube] dQw4w9WgXcQ: Downloading ios music player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (3/3)...
[youtube] dQw4w9WgXcQ: Downloading ios music player API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)
[debug] [youtube] Extracting signature function js_4e23410d_111
[debug] Loading youtube-sigfuncs.js_4e23410d_111 from cache
[debug] Loading youtube-nsig.4e23410d from cache
[debug] [youtube] Decrypted nsig FWB71e2YaILzV4Jk6 => c9DtuMX86FuFLg
[debug] Loading youtube-nsig.4e23410d from cache
[debug] [youtube] Decrypted nsig ntd9OrqYeHwbeFAZW => I7n4wL1bNcbp_A
[debug] [youtube] Extracting signature function js_4e23410d_107
[debug] Loading youtube-sigfuncs.js_4e23410d_107 from cache
[youtube] dQw4w9WgXcQ: Downloading m3u8 information
WARNING: [youtube] Incomplete data received in embedded initial data; re-fetching using API.
[youtube] dQw4w9WgXcQ: Downloading initial data API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (1/3)...
[youtube] dQw4w9WgXcQ: Downloading initial data API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (2/3)...
[youtube] dQw4w9WgXcQ: Downloading initial data API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
WARNING: [youtube] HTTP Error 400: Bad Request. Retrying (3/3)...
[youtube] dQw4w9WgXcQ: Downloading initial data API JSON
WARNING: [youtube] YouTube said: ERROR - Request contains an invalid argument.
ERROR: [youtube] dQw4w9WgXcQ: Unable to download API page: HTTP Error 400: Bad Request (caused by <HTTPError 400: Bad Request>)
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 742, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/youtube.py", line 4902, in _real_extract
    initial_data = self._extract_response(
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/youtube.py", line 1270, in _extract_response
    next(main_retries)
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/utils/_utils.py", line 5271, in __iter__
    self.error_callback(self.error, self.attempt, self.retries)
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 3896, in _error_or_warning
    RetryManager.report_retry(
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/utils/_utils.py", line 5279, in report_retry
    raise e
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/youtube.py", line 1243, in _extract_response
    response = self._call_api(
               ^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/youtube.py", line 861, in _call_api
    return self._download_json(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 1153, in download_content
    res = getattr(self, download_handle.__name__)(url_or_request, video_id, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 1113, in download_handle
    res = self._download_webpage_handle(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 963, in _download_webpage_handle
    urlh = self._request_webpage(url_or_request, video_id, note, errnote, fatal, data=data,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 912, in _request_webpage
    raise ExtractorError(errmsg, cause=err)

  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/networking/_urllib.py", line 398, in _send
    res = opener.open(urllib_req, timeout=self._calculate_timeout(request))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/extractor/common.py", line 898, in _request_webpage
    return self._downloader.urlopen(self._create_request(url_or_request, data, headers, query, extensions))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/YoutubeDL.py", line 4162, in urlopen
    return self._request_director.send(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/networking/common.py", line 117, in send
    response = handler.send(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/networking/_helper.py", line 208, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/networking/common.py", line 340, in send
    return self._send(request)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/jake/yt-dlp/lib/python3.11/site-packages/yt_dlp/networking/_urllib.py", line 403, in _send
    raise HTTPError(UrllibResponseAdapter(e.fp), redirect_loop='redirect error' in str(e)) from e
yt_dlp.networking.exceptions.HTTPError: HTTP Error 400: Bad Request

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Unfortunately trying just a music URL with both android_music and web_music still resulted in the same 400 error. I have a feeling A/B test theory is the most likely.