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

HTTP Basic Authentication does not work on http://www.cs.sjsu.edu/~stamp/infosec/lectures/ #21784

Closed
agyild opened this issue Jul 14, 2019 · 2 comments

Comments

@agyild
Copy link

@agyild agyild commented Jul 14, 2019

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2019.07.14
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

[debug] System config: []
[debug] User config: ['--geo-bypass']
[debug] Custom config: []
[debug] Command-line args: ['-v', '-F', '-u', 'PRIVATE', '-p', 'PRIVATE', 'http://www.cs.sjsu.edu/~stamp/infosec/lectures/CS166_Spr18/CS166_4_3_18.mp4']
[debug] Encodings: locale cp1252, fs utf-8, out cp1252, pref cp1252
[debug] youtube-dl version 2019.07.12
[debug] Python version 3.7.3 (CPython) - Windows-10-10.0.18362-SP0
[debug] exe versions: ffmpeg N-93482-g9dece050ef
[debug] Proxy map: {}
WARNING: Could not send HEAD request to http://www.cs.sjsu.edu/~stamp/infosec/lectures/CS166_Spr18/CS166_4_3_18.mp4: HTTP Error 401: Unauthorized
ERROR: Unable to download webpage: HTTP Error 401: Unauthorized (caused by <HTTPError 401: 'Unauthorized'>); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "c:\program files\python37\lib\site-packages\youtube_dl\extractor\common.py", line 627, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "c:\program files\python37\lib\site-packages\youtube_dl\YoutubeDL.py", line 2227, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "c:\program files\python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "c:\program files\python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "c:\program files\python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "c:\program files\python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "c:\program files\python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)

[generic] CS166_4_3_18: Requesting header
[generic] CS166_4_3_18: Downloading webpage

Description

The following command does not work as expected:

youtube-dl -v -F -u infosec -p infosec http://www.cs.sjsu.edu/~stamp/infosec/lectures/CS166_Spr18/CS166_4_3_18.mp4

I have also tried authenticating with .netrc file, passing username and password in the URL request (e.g. http://username:password@example.com). The results are the same. The directory and the videos open fine in a browser.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jul 14, 2019

It's not supposed to. You must pass correct Authorization header.

@dstftw dstftw closed this Jul 14, 2019
@agyild
Copy link
Author

@agyild agyild commented Jul 15, 2019

OK, solved it by passing the Authorization header with --add-header option. (e.g. --add-header=Authorization:"Basic dXNlcm5hbWU6cGFzc3dvcmQ="
Also since it was actually for streaming with mpv, I have just discovered mpv has native support for streaming HTTP Basic authorized content via ffmpeg. One just has to request it directly with mpv, e.g:

mpv https://username:password@example.com/example.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.