{"record":{"id":"fa4b6b12ce6c3757","repo":"ytdl-org/youtube-dl","slug":"unable-to-login-twitch-said-s","errorCode":null,"errorMessage":"Unable to login. Twitch said: %s","messagePattern":"Unable to login\\. Twitch said: (.+?)","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/twitch.py","lineNumber":66,"sourceCode":"        'ClipsCards__User': 'b73ad2bfaecfd30a9e6c28fada15bd97032c83ec77a0440766a56fe0bd632777',\n        'ChannelCollectionsContent': '07e3691a1bad77a36aba590c351180439a40baefc1c275356f40fc7082419a84',\n        'StreamMetadata': '1c719a40e481453e5c48d9bb585d971b8b372f8ebb105b17076722264dfa5b3e',\n        'ComscoreStreamingQuery': 'e1edae8122517d013405f237ffcc124515dc6ded82480a88daef69c83b53ac01',\n        'VideoAccessToken_Clip': '36b89d2507fce29e5ca551df756d27c1cfe079e2609642b4390aa4c35796eb11',\n        'VideoPreviewOverlay': '3006e77e51b128d838fa4e835723ca4dc9a05c5efd4466c1085215c6e437e65c',\n        'VideoMetadata': '226edb3e692509f727fd56821f5653c05740242c82b0388883e0c0e75dcbf687',\n    }\n\n    def _real_initialize(self):\n        self._login()\n\n    def _login(self):\n        username, password = self._get_login_info()\n        if username is None:\n            return\n\n        def fail(message):\n            raise ExtractorError(\n                'Unable to login. Twitch said: %s' % message, expected=True)\n\n        def login_step(page, urlh, note, data):\n            form = self._hidden_inputs(page)\n            form.update(data)\n\n            page_url = urlh.geturl()\n            post_url = self._search_regex(\n                r'<form[^>]+action=([\"\\'])(?P<url>.+?)\\1', page,\n                'post url', default=self._LOGIN_POST_URL, group='url')\n            post_url = urljoin(page_url, post_url)\n\n            headers = {\n                'Referer': page_url,\n                'Origin': 'https://www.twitch.tv',\n                'Content-Type': 'text/plain;charset=UTF-8',\n            }\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/twitch.py#L48-L84","documentation":"Raised by TwitchTvIE._login (via the local fail() helper) when a step of the interactive login flow reports an error — e.g. wrong credentials, CAPTCHA/verification wall, or 'blocked' message parsed from the login pages. Expected error: the message after 'Twitch said:' comes from Twitch's response, not youtube-dl.","triggerScenarios":"Running with --username/--password so _get_login_info() returns credentials, then a login_step POST returns a page containing an error/authy/captcha/blocked marker, triggering fail(message). Twitch may also step up with 2FA prompts that youtube-dl cannot answer.","commonSituations":"Incorrect or expired password, Twitch forcing CAPTCHA or device verification on automated logins, 2FA-enabled accounts, using --twofactor incorrectly.","solutions":["Use cookie-based auth instead: log in with a browser, export cookies, and pass --cookies twitch_cookies.txt.","Verify credentials work in a browser; reset password if not.","Supply --twofactor <code> if the account has 2FA.","Update to yt-dlp, where Twitch login handling was reworked (and cookie auth is the recommended path)."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    ydl.extract_info(url)\nexcept ExtractorError as e:\n    if 'Unable to login' in str(e):\n        switch_to_cookie_auth()  # re-run with --cookies from browser session\n    else:\n        raise","preventionTips":["Prefer --cookies exported from a logged-in browser over --username/--password for Twitch.","Provide --twofactor for 2FA accounts; never retry password login in a loop (triggers harder CAPTCHAs)."],"tags":["authentication","twitch","captcha","cookies","login"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}