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

Facebook login TWOFACTOR functionality missing #30337

Open
wsbblyy opened this issue Dec 8, 2021 · 5 comments
Open

Facebook login TWOFACTOR functionality missing #30337

wsbblyy opened this issue Dec 8, 2021 · 5 comments

Comments

@wsbblyy
Copy link

wsbblyy commented Dec 8, 2021

Checklist

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

Verbose log

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-2', '721664', '-v', 'https://www.facebook.com/106937041769662/videos/601957961078153/']
[debug] Encodings: locale cp936, fs utf-8, out utf-8, pref cp936
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.8.8 (CPython) - Windows-10-10.0.19041-SP0
[debug] exe versions: none
[debug] Proxy map: {}
[facebook] Downloading login page
[facebook] Logging in
[facebook] 601957961078153: Downloading webpage
ERROR: This video is only available for registered users. Use --username and --password or --netrc to provide account credentials.
Traceback (most recent call last):
  File "c:\users\administrator\anaconda3\lib\site-packages\youtube_dl\YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "c:\users\administrator\anaconda3\lib\site-packages\youtube_dl\YoutubeDL.py", line 836, in __extract_info
    ie_result = ie.extract(url)
  File "c:\users\administrator\anaconda3\lib\site-packages\youtube_dl\extractor\common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "c:\users\administrator\anaconda3\lib\site-packages\youtube_dl\extractor\facebook.py", line 680, in _real_extract
    return self._extract_from_url(real_url, video_id)
  File "c:\users\administrator\anaconda3\lib\site-packages\youtube_dl\extractor\facebook.py", line 528, in _extract_from_url
    self.raise_login_required()
  File "c:\users\administrator\anaconda3\lib\site-packages\youtube_dl\extractor\common.py", line 941, in raise_login_required
    raise ExtractorError(
youtube_dl.utils.ExtractorError: This video is only available for registered users. Use --username and --password or --netrc to provide account credentials.

Description

Trying to download a facebook post video, debug log shows I successfully logged in, but still shows This video is only available for registered users.. I went thru the facebook login code, didn't find anything about TWOFACTOR functionality, am I missing something?

@october262
Copy link

see under authentication options - https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme

@wsbblyy
Copy link
Author

wsbblyy commented Dec 9, 2021

Thanks for reply, if you see the Command-line args in my debug log, I did pass the -2 argument, and I tried multiple times, it always give me this error ERROR: This video is only available for registered users.

see under authentication options - https://github.com/ytdl-org/youtube-dl/blob/master/README.md#readme

@october262
Copy link

strange, i was able to download this video - https://www.facebook.com/106937041769662/videos/601957961078153/
without any authentication. are you signed in to your facebook account ??

@wsbblyy
Copy link
Author

wsbblyy commented Dec 9, 2021

Yes, I signed in to my Facebook account, but it didn't go thru the 2 factor approvals, the program should perform like this:
sign in --> 2 factor approvals --> go download videos,
I debugged the code a little bit, I think it doesn't do anything about the 2 factor approvals part.
I assume you don't have the 2 factor approvals on you facebook account that's why you can download the video.
The following code is from the youtube-dl library ./extractor/facebook.py 343-360, which performs facebook login, and I didn't find anything about the 2 factor approvals.

login_results = self._download_webpage(request, None,note='Logging in', errnote='unable to fetch login page')
if re.search(r'<form(.*)name="login"(.*)</form>', login_results) is not None:
    error = self._html_search_regex(
                   r'(?s)<div[^>]+class=(["\']).*?login_error_box.*?\1[^>]*><div[^>]*>.*?</div><div[^>]*>(?P<error>.+?)</div>',
                   login_results, 'login error', default=None, group='error')
    if error:
        raise ExtractorError('Unable to login: %s' % error, expected=True)
    self._downloader.report_warning('unable to log in: bad username/password, or exceeded login rate limit (~3/min). Check credentials or wait.')
    return

    fb_dtsg = self._search_regex(r'name="fb_dtsg" value="(.+?)"', login_results, 'fb_dtsg', default=None)
    h = self._search_regex(r'name="h"\s+(?:\w+="[^"]+"\s+)*?value="([^"]+)"', login_results, 'h', default=None)

    if not fb_dtsg or not h:
        return

strange, i was able to download this video - https://www.facebook.com/106937041769662/videos/601957961078153/ without any authentication. are you signed in to your facebook account ??

@ghost
Copy link

ghost commented Dec 10, 2021

Facebook is tricky. Even if a video can be viewed without login, the login page may be returned to youtube-dl. If there's no problem at first, the login page may be returned even to browsers after repeated attempts. Or It may be related to your location or network.

For your URL, I too can download the video without login info. If I use a proxy in other countries, sometimes login page is returned, sometimes still no problem.

What users can do would be:

  • try --cookies (without -u and -p)
    but you may get blocked if you try many times
  • try --proxy in other countries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants