From 4999a3f74b1756ae9196484a926e352b09b36b5e Mon Sep 17 00:00:00 2001 From: "Mikhail Andreev (adw0rd)" Date: Tue, 4 Jan 2022 19:14:16 +0300 Subject: [PATCH 1/4] Fix version of requests==2.26.0 (Error: 407 Proxy Authentication Required) --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 105124c..f19e8e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ fastapi==0.65.1 uvicorn==0.11.3 ipython>=7.17.0 -instagrapi>=1.12.19 +instagrapi>=1.16.11 python-multipart==0.0.5 Pillow==8.1.1 moviepy==1.0.3 @@ -10,7 +10,7 @@ httpx==0.17.1 pudb==2021.1 ipdb==0.13.9 aiofiles==0.7.0 -requests<3.0,>=2.25.1 +requests==2.26.0 starlette~=0.14.2 pytest~=6.2.4 tinydb==4.5.1 From 3a196e3ce33059d31ae7e017b1834d3369f0ea8b Mon Sep 17 00:00:00 2001 From: gholamrezaeipt <90236081+gholamrezaeipt@users.noreply.github.com> Date: Sun, 16 Jan 2022 10:15:12 +0330 Subject: [PATCH 2/4] Update instagrapi to last release According to https://github.com/adw0rd/instagrapi/commit/b7c2dc5551375dfd0cd32786b25b3e1c4e3232e1#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f19e8e4..b13066d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ fastapi==0.65.1 uvicorn==0.11.3 ipython>=7.17.0 -instagrapi>=1.16.11 +instagrapi>=1.16.12 python-multipart==0.0.5 Pillow==8.1.1 moviepy==1.0.3 From 4d04300431066b0994ea830c1e7436c5f45477cc Mon Sep 17 00:00:00 2001 From: "Michel G. Souza" Date: Thu, 24 Feb 2022 15:01:42 -0300 Subject: [PATCH 3/4] fix a typo POST method instead GET --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 448aeef..d6d6112 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ Open in browser [http://localhost:8000/docs](http://localhost:8000/docs) and fol Get sessionid: ``` -curl -X 'GET' \ +curl -X 'POST' \ 'http://localhost:8000/auth/login' \ -H 'accept: application/json' \ -H 'Content-Type: application/x-www-form-urlencoded' \ From 30ad64c26f83660368fb0f2f74348bc18eb1c149 Mon Sep 17 00:00:00 2001 From: "Michel G. Souza" Date: Thu, 3 Mar 2022 09:05:39 -0300 Subject: [PATCH 4/4] Fix code indentation --- routers/auth.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/routers/auth.py b/routers/auth.py index 2fab8c7..1234f12 100644 --- a/routers/auth.py +++ b/routers/auth.py @@ -9,6 +9,14 @@ responses={404: {"description": "Not found"}} ) + +def challenge_code_handler(username, choice, challenge_url, session=None): + # Aqui salva o challenge_url e os headers e os cookies que tão nessa session + print(f"username:{username} \n CHOICE:{choice}") + print(f"URL:{challenge_url} \n session {session}") + + return False + @router.post("/login") async def auth_login(username: str = Form(...), password: str = Form(...), @@ -20,6 +28,8 @@ async def auth_login(username: str = Form(...), """Login by username and password with 2FA """ cl = clients.client() + cl.challenge_code_handler = challenge_code_handler + if proxy != "": cl.set_proxy(proxy) @@ -49,6 +59,23 @@ async def auth_relogin(sessionid: str = Form(...), result = cl.relogin() return result +@router.post("/challenge_code") +async def challenge_code(sessionid: str = Form(...), + code: str = Form(...), + clients: ClientStorage = Depends(get_clients)) -> str: + """ Challenge code + """ + cl = clients.get(sessionid) + + ## Aqui você puxa os headers, os cookies e o challenge_url que você salvou na linha 14 e chama o checkpoint_resume + old_session = "" + challenge_url = "" + if(old_session): + result = cl.resume_checkpoint(code, challenge_url, old_session) + else: + result = cl.send_checkpoint_code(code, challenge_url) + return result + @router.get("/settings/get") async def settings_get(sessionid: str,