Skip to content

Commit e15fee3

Browse files
authored
Merge pull request #155 from LucasLeRay/add-alternate-identifier-task
Add alternate identifier login task
2 parents 00a8e07 + 21ed2a0 commit e15fee3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

twscrape/login.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ async def login_initiate(client: AsyncClient) -> Response:
4747
return rep
4848

4949

50+
async def login_alternate_identifier(ctx: TaskCtx, *, username: str) -> Response:
51+
payload = {
52+
"flow_token": ctx.prev["flow_token"],
53+
"subtask_inputs": [
54+
{
55+
"subtask_id": "LoginEnterAlternateIdentifierSubtask",
56+
"enter_text": {"text": username, "link": "next_link"},
57+
}
58+
],
59+
}
60+
61+
rep = await ctx.client.post(LOGIN_URL, json=payload)
62+
raise_for_status(rep, "login_alternate_identifier")
63+
return rep
64+
65+
5066
async def login_instrumentation(ctx: TaskCtx) -> Response:
5167
payload = {
5268
"flow_token": ctx.prev["flow_token"],
@@ -200,6 +216,8 @@ async def next_login_task(ctx: TaskCtx, rep: Response):
200216
return await login_enter_username(ctx)
201217
if task_id == "LoginJsInstrumentationSubtask":
202218
return await login_instrumentation(ctx)
219+
if task_id == "LoginEnterAlternateIdentifierSubtask":
220+
return await login_alternate_identifier(ctx, username=ctx.acc.username)
203221
except Exception as e:
204222
ctx.acc.error_msg = f"login_step={task_id} err={e}"
205223
raise e

0 commit comments

Comments
 (0)