Twitch: login failure due to missing twitchguard code
See original GitHub issueChecklist
- I’m reporting a broken site support
- I’ve verified that I’m running youtube-dl version 2019.11.28
- 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 issues including closed ones
Verbose log
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['https://www.twitch.tv/videos/<redacted>', '-u', 'PRIVATE', '-v']
Type account password and press [Return]:
[debug] Encodings: locale cp1252, fs mbcs, out cp850, pref cp1252
[debug] youtube-dl version 2019.11.28
[debug] Python version 3.4.4 (CPython) - Windows-10-10.0.18362
[debug] exe versions: ffmpeg N-92498-g77bf85515e, ffprobe N-92498-g77bf85515e
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Logging in
ERROR: Unable to login. Twitch said: missing twitchguard code
Traceback (most recent call last):
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\YoutubeDL.py", line 796, in extract_info
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\extractor\common.py", line 529, in extract
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\extractor\common.py", line 433, in initialize
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\extractor\twitch.py", line 64, in _real_initialize
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\extractor\twitch.py", line 119, in _login
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\extractor\twitch.py", line 96, in login_step
File "C:\Users\dst\AppData\Roaming\Build archive\youtube-dl\ytdl-org\tmpwy0zjfmc\build\youtube_dl\extractor\twitch.py", line 73, in fail
youtube_dl.utils.ExtractorError: Unable to login. Twitch said: missing twitchguard code
Description
On trying to download a video from Twitch, I received the error as shown above. The video is open to subscribers only at the moment, hence the need to provide a username (with -u) and provide the account password at the prompt. On providing the password, login fails with a “missing twitchguard code” error message.
I ran youtube-dl again with --dump-pages and it shows:
[debug] Proxy map: {}
[twitch:vod] Downloading login page
[twitch:vod] Dumping request to https://www.twitch.tv/login
<large base64 encoded dump>
[twitch:vod] Logging in
[twitch:vod] Dumping request to https://passport.twitch.tv/login
<smaller base64 encoded dump>
ERROR: Unable to login. Twitch said: missing twitchguard code
The smaller base64 encoded dump, decoded with base64.b64decode(dump), shows:
b'{"captcha_proof":"<redacted>","error":"Please enter a Login Verification Code.","error_code":3022,"error_description":"missing twitchguard code"}'
It seems like Twitch have introduced a form of login verification - I received an email from Twitch with the subject “Your Twitch Login Verification Code” shortly after running youtube-dl, however there is no prompt by youtube-dl to provide this code in order to continue logging in.
As a note, if I enter an invalid password for the account, I still get youtube_dl.utils.ExtractorError: Unable to login. Twitch said: invalid password
so I am sure that the above error occurs after the password has been validated as correct by Twitch.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:11
@PolygraphMusic
The only workaround at the moment seems to be to use the
--cookies
option for youtube-dl as detailed here.In short:
.twitch.tv
from your browser (see the link above for extensions that do this extraction for you) tocookies.txt
youtube-dl.exe --cookies=cookies.txt https://www.twitch.tv/videos/<numeric_id>
(do not use the youtube-dl--username
or--password
options in this case)This patch worked for me. I didn’t see a generic way of passing cli params into InfoExtractor objects on/after creation, so I updated
YoutubeDL.extract_info
method to check for the new--twitch-guard-code
cli param, and set it in the info extractor object if found. The twitch info extractors then include it during auth if it’s set.I applied the patch to a fork of youtube-dl, but I’m not going to PR it because there should be a more generic way of applying cli params to arbitrary IE’s.
With the patch, the workflow is:
youtube-dl
commandyoutube-dl
command, this time with--twitch-guard-code
specified for the code in your emailUpdate: Twitch now returns
ERROR: Unable to login. Twitch said: captcha incorrect
so the patch isn’t a solution anymore. Captcha would need to be determined and included in a"captcha":{"proof":"_stuff here_"}
part of the auth payload.