youtube-dl: [YouTube] Unable to authenticate with enabled TFA
Make sure you are using the latest version: run youtube-dl --version
and ensure your version is 2017.12.31. If it’s not, read this FAQ entry and update. Issues with outdated version will be rejected.
- I’ve verified and I assure that I’m running youtube-dl 2017.12.31
D:\downloaded_audio
λ youtube-dl --version
2017.12.31
Before submitting an issue make sure you have:
- At least skimmed through the README, most notably the FAQ and BUGS sections
- Searched the bugtracker for similar issues including closed ones
What is the purpose of your issue?
- Bug report (encountered problems with youtube-dl)
- Site support request (request for adding support for a new site)
- Feature request (request for a new functionality)
- Question
- Other
If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:
Add the -v
flag to your command line you run youtube-dl with (youtube-dl -v <your command line>
), copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):
[debug] System config: []
[debug] User config: ['-x', '--audio-format', 'mp3', '--audio-quality', '0']
[debug] Custom config: []
[debug] Command-line args: ['-n', '-v', 'https://www.youtube.com/watch?v=tM8x5Zhe5O0']
[debug] Encodings: locale cp1251, fs utf-8, out utf-8, pref cp1251
[debug] youtube-dl version 2017.12.31
[debug] Python version 3.6.3 - Windows-10-10.0.16299-SP0
[debug] exe versions: ffmpeg N-88355-g05beee44c6, ffprobe N-88355-g05beee44c6
[debug] Proxy map: {}
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
Type 2-step verification code and press [Return]:
[youtube] Submitting TFA code
WARNING: Unable to submit TFA code: HTTP Error 400: Bad Request
WARNING: Unable to extract CheckCookie URL
[youtube] tM8x5Zhe5O0: Downloading webpage
[youtube] tM8x5Zhe5O0: Downloading video info webpage
ERROR: tM8x5Zhe5O0: YouTube said: Please sign in to view this video.
Traceback (most recent call last):
File "d:\program files\python36-32\lib\site-packages\youtube_dl\YoutubeDL.py", line 784, in extract_info
ie_result = ie.extract(url)
File "d:\program files\python36-32\lib\site-packages\youtube_dl\extractor\common.py", line 438, in extract
ie_result = self._real_extract(url)
File "d:\program files\python36-32\lib\site-packages\youtube_dl\extractor\youtube.py", line 1609, in _real_extract
expected=True, video_id=video_id)
youtube_dl.utils.ExtractorError: tM8x5Zhe5O0: YouTube said: Please sign in to view this video.
[debug] System config: []
[debug] User config: ['-x', '--audio-format', 'mp3', '--audio-quality', '0']
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-v', 'https://www.youtube.com/watch?v=tM8x5Zhe5O0']
[debug] Encodings: locale cp1251, fs utf-8, out utf-8, pref cp1251
[debug] youtube-dl version 2017.12.31
[debug] Python version 3.6.3 - Windows-10-10.0.16299-SP0
[debug] exe versions: ffmpeg N-88355-g05beee44c6, ffprobe N-88355-g05beee44c6
[debug] Proxy map: {}
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
Type 2-step verification code and press [Return]:
[youtube] Submitting TFA code
WARNING: Unable to submit TFA code: HTTP Error 400: Bad Request
WARNING: Unable to extract CheckCookie URL
[youtube] tM8x5Zhe5O0: Downloading webpage
[youtube] tM8x5Zhe5O0: Downloading video info webpage
ERROR: tM8x5Zhe5O0: YouTube said: Please sign in to view this video.
Traceback (most recent call last):
File "d:\program files\python36-32\lib\site-packages\youtube_dl\YoutubeDL.py", line 784, in extract_info
ie_result = ie.extract(url)
File "d:\program files\python36-32\lib\site-packages\youtube_dl\extractor\common.py", line 438, in extract
ie_result = self._real_extract(url)
File "d:\program files\python36-32\lib\site-packages\youtube_dl\extractor\youtube.py", line 1609, in _real_extract
expected=True, video_id=video_id)
youtube_dl.utils.ExtractorError: tM8x5Zhe5O0: YouTube said: Please sign in to view this video.
[debug] System config: []
[debug] User config: ['-x', '--audio-format', 'mp3', '--audio-quality', '0']
[debug] Custom config: []
[debug] Command-line args: ['-u', 'PRIVATE', '-p', 'PRIVATE', '-2', '123456', '-v', 'https://www.youtube.com/watch?v=tM8x5Zhe5O0']
[debug] Encodings: locale cp1251, fs utf-8, out utf-8, pref cp1251
[debug] youtube-dl version 2017.12.31
[debug] Python version 3.6.3 - Windows-10-10.0.16299-SP0
[debug] exe versions: ffmpeg N-88355-g05beee44c6, ffprobe N-88355-g05beee44c6
[debug] Proxy map: {}
[youtube] Downloading login page
[youtube] Looking up account info
[youtube] Logging in
[youtube] Submitting TFA code
WARNING: Unable to submit TFA code: HTTP Error 400: Bad Request
WARNING: Unable to extract CheckCookie URL
[youtube] tM8x5Zhe5O0: Downloading webpage
[youtube] tM8x5Zhe5O0: Downloading video info webpage
ERROR: tM8x5Zhe5O0: YouTube said: Please sign in to view this video.
Traceback (most recent call last):
File "d:\program files\python36-32\lib\site-packages\youtube_dl\YoutubeDL.py", line 784, in extract_info
ie_result = ie.extract(url)
File "d:\program files\python36-32\lib\site-packages\youtube_dl\extractor\common.py", line 438, in extract
ie_result = self._real_extract(url)
File "d:\program files\python36-32\lib\site-packages\youtube_dl\extractor\youtube.py", line 1609, in _real_extract
expected=True, video_id=video_id)
youtube_dl.utils.ExtractorError: tM8x5Zhe5O0: YouTube said: Please sign in to view this video.
Description of your issue, suggested solution and other information
Unable to authenticate with enabled TFA on account.
Returns HTTP Error 400 after typing 2-step verification code.
Happens in any way of authentication: .netrc
, direct passing login+pass via cmd args, direct passing login+pass+tfacode via cmd args.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 12
- Comments: 30 (1 by maintainers)
Receiving same error with Python 2.7.x
@Vulp35 I’m working on a fix. What 2FA methods (Authenticator code, texted code, prompt in Google/Gmail app) do you have turned on on your Google account? Which one is the default, the one it asks for when you try to log in with a browser (use incognito if you don’t know)?
Found the same issue just now when attempting to grab my Watch Later for a flight.
EDIT: updated to current and re-ran
I am having the same difficulty with the version 2018.11.23 and the forked version that was modified by @eduardog3000 . This was difficult to test on Windows without an executable, but I figured it out. In any case, when I temporarily disable 2FA on my account, both the stock and modified versions worked for me. So I am not sure what the fix was supposed to do, but I saw no change in behavior.
@eduardog3000 oh gotcha! Yup can also confirm it working with prompt enabled as the default but using a code from Authenticator in youtube-dl
@Vulp35 youtube-dl can’t actually use the prompt, it still needs the Google Authenticator code, but I wanted to make sure that someone with the prompt enabled was still able to use the code through youtube-dl. The way the fix works I wasn’t completely sure it would work when Google asks for the prompt by default.
Oh, good, Prompt started working for me (you can see in my image above I got locked out of it), so I could test it myself.
Looks like all is good, I’ll submit the PR.
I can add prompt as well if that helps you.
Also, can confirm this fix is working with the Authenticator App 😃
Correct, that’s what I see after using a browser in Privacy mode.
@sandalle
$ youtube-dl -u sandalle@gmail.com -p -2 https://www.youtube.com/watch?v=UcRZQL-grSs
is because you have the syntax wrong, you have to put your 6 digit TOTP code after-2
.But it’s good to see my code works for you. Just to be sure, this is the very first screen you see after inputting your password in a normal browser?
Not something like this:
If I were you I’d mask your logins.
@eduardog3000
I’m unsure why those aren’t working, but using my ~/.netrc values worked in that I got
HTTP Error 500
for 2FA:I’ve cloned git@github.com:eduardog3000/youtube-dl.git seems to work with 2FA. 😃
I also tried downloading a playlist, and the first item worked with 2FA and the second continued to work with the 2FA session. 😃
@sandalle What error do you get when you try to log in with youtube-dl?
HTTP Error 500: Internal Server Error
orHTTP Error 400: Bad Request
.Then can you download this branch and tell me what happens when you try to log in (use
python -m youtube_dl -v <args>
to run directly from the code).@eduardog3000 , for mine, my YouTube 2FA is via Google Authenticator.