From c18c7a0128cf5da3c20028d383ff44434a2fe9f4 Mon Sep 17 00:00:00 2001 From: trojvn Date: Thu, 6 Nov 2025 22:56:54 +0300 Subject: [PATCH] with twostep --- auth.py | 27 +++++++++++++++++++++++++++ wrapper.py | 17 +++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 auth.py diff --git a/auth.py b/auth.py new file mode 100644 index 0000000..32296cc --- /dev/null +++ b/auth.py @@ -0,0 +1,27 @@ +import asyncio + +from jsoner import json_read_async + +from models import UdidInfo +from wrapper import IPAToolClient + + +async def main(): + json_data = await json_read_async("info.json") + for udid, value in json_data.items(): + info = UdidInfo(**value) + client = IPAToolClient(info.host, info.port) + if not await client.auth(info.user, info.pswd): + print(udid, "no auth response") + continue + print(udid, "auth success") + if not client.auth_check(info.user): + code = input(f"Enter the code for {udid}: ") + if not await client.auth_twostep(info.user, info.pswd, code): + print(udid, "no twostep response") + continue + print(udid, "twostep success") + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/wrapper.py b/wrapper.py index 5a20ad3..0f2bc0f 100644 --- a/wrapper.py +++ b/wrapper.py @@ -36,6 +36,23 @@ class IPAToolClient(BaseAsyncClient): return json_data return False + async def auth_twostep(self, user: str, pswd: str, code: str): + r = await self._post( + "/auth/twostep", + params={ + "user": user, + "pswd": pswd, + "code": code, + "keychain": pswd, + }, + ) + if r.status != 200: + return False + json_data = await r.json() + if isinstance(json_data, bool): + return json_data + return False + async def app_info(self, query: str, limit: int, keychain: str) -> dict: r = await self._post( "/app/search",