From e921e9e40878cfe2fc7723d8a5a769ac9400f65f Mon Sep 17 00:00:00 2001 From: Vlad Pronsky Date: Wed, 17 Apr 2024 01:53:03 +0300 Subject: [PATCH] fix login when no ct0 found #143 --- twscrape/login.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/twscrape/login.py b/twscrape/login.py index 592946f..5c8c99b 100644 --- a/twscrape/login.py +++ b/twscrape/login.py @@ -242,11 +242,11 @@ async def login(acc: Account, cfg: LoginConfig | None = None) -> Account: rep = await login_initiate(client) ctx = TaskCtx(client, acc, cfg, None, imap) while True: + rep = await next_login_task(ctx, rep) if not rep: break - rep = await next_login_task(ctx, rep) - + assert "ct0" in client.cookies, "ct0 not in cookies (most likely ip ban)" client.headers["x-csrf-token"] = client.cookies["ct0"] client.headers["x-twitter-auth-type"] = "OAuth2Session"