Skip to content

Commit

Permalink
allow prompt_mfa to be async
Browse files Browse the repository at this point in the history
  • Loading branch information
matin committed May 18, 2024
1 parent 316787d commit ae1b425
Show file tree
Hide file tree
Showing 4 changed files with 1,172 additions and 2 deletions.
6 changes: 5 additions & 1 deletion garth/sso.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import re
import time
from typing import Callable, Dict, Optional, Tuple
Expand Down Expand Up @@ -150,7 +151,10 @@ def handle_mfa(
client: "http.Client", signin_params: dict, prompt_mfa: Callable
) -> None:
csrf_token = get_csrf_token(client.last_resp.text)
mfa_code = prompt_mfa()
if asyncio.iscoroutinefunction(prompt_mfa):
mfa_code = asyncio.run(prompt_mfa())
else:
mfa_code = prompt_mfa()
client.post(
"sso",
"/sso/verifyMFA/loginEnterMfaCode",
Expand Down
2 changes: 1 addition & 1 deletion garth/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.45"
__version__ = "0.4.46"
Loading

0 comments on commit ae1b425

Please sign in to comment.