question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Twitch: login failure due to missing twitchguard code

See original GitHub issue

Checklist

  • 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:open
  • Created 4 years ago
  • Reactions:10
  • Comments:11

github_iconTop GitHub Comments

24reactions
david-wm-sanderscommented, Dec 20, 2019

@PolygraphMusic

The only workaround at the moment seems to be to use the --cookies option for youtube-dl as detailed here.

In short:

  1. Extract the cookies for domain .twitch.tv from your browser (see the link above for extensions that do this extraction for you) to cookies.txt
  2. Run 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)
3reactions
colakongcommented, Dec 17, 2019

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:

  1. Issue the youtube-dl command
  2. Login fails, you get an email with twitch guard code
  3. Issue same youtube-dl command, this time with --twitch-guard-code specified for the code in your email

Update: 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Twitch Account Access/Login Issues Guide
This article addresses common account & login issues. ... If you have lost access to the email listed on your account, please head...
Read more >
Twitch Login Issues - Authy
Twitch Streamers and some viewers may not be able to successfully login to ... if they are unable to access the Authy two-factor...
Read more >
Twitch down? Current status and problems - Downdetector
Select the option you are having issues with, and help provide feedback to the service. Website Video Streaming Login Something else... Twitch ......
Read more >
How do you disable the email authentication? : r/Twitch - Reddit
13 votes, 15 comments. So every time I login to my Twitch account, I get prompted an email notification for a code. It...
Read more >
Troubleshooting: Twitch.TV login problems and Elgato Game ...
1) Log out of Twitch in Safari · 2) Clear the Safari cache · 3) Erase any cookies specifically related to Twitch in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found