Minor changes
This commit is contained in:
parent
92c36cb6e8
commit
a0c17df7da
11
src/main.py
11
src/main.py
|
@ -207,8 +207,14 @@ async def main(arguments: argparse.Namespace) -> int:
|
|||
if not arguments.tax_code:
|
||||
logger.info("You have not provided your tax/fiscal code, but I can get it for you. Please provide your GIA SSO"
|
||||
" credentials below")
|
||||
try:
|
||||
username = input("Type your GIA SSO username: ")
|
||||
password = getpass("Type your GIA SSO password (hidden): ")
|
||||
except KeyboardInterrupt:
|
||||
# Asyncio's signal handlers won't work
|
||||
# when blocked in synchronous code like
|
||||
# this
|
||||
return
|
||||
logger.info(f"Logging in as {username!r}")
|
||||
if access_token := await login_with_gia(logger, username, password, arguments.verbose):
|
||||
logger.debug(f"Access token is {access_token!r}")
|
||||
|
@ -222,7 +228,7 @@ async def main(arguments: argparse.Namespace) -> int:
|
|||
return -1
|
||||
logger.info(f"Authenticating as '{arguments.tax_code}'")
|
||||
async with httpx.AsyncClient(
|
||||
# We mimic the app's headers
|
||||
# We mimic the app's headers. Specifically, this is my Xiaomi Mi 11i, lol
|
||||
headers={
|
||||
"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 11; M2012K11G Build/RKQ1.201112.002)",
|
||||
# I seriously have no idea what the app designers were thinking, but
|
||||
|
@ -249,6 +255,7 @@ async def main(arguments: argparse.Namespace) -> int:
|
|||
):
|
||||
return 1
|
||||
logger.debug(f"Request to {result.url} sent, status code is {result.status_code}")
|
||||
try:
|
||||
if json.loads(result.text) != {}:
|
||||
# The API returns an empty JSON object to unauthenticated
|
||||
# requests
|
||||
|
@ -308,6 +315,8 @@ async def main(arguments: argparse.Namespace) -> int:
|
|||
else:
|
||||
logger.error(f"The provided tax code does not appear to be valid, please check for any typos and try again")
|
||||
return -1
|
||||
except json.decoder.JSONDecodeError as json_error:
|
||||
logger.error(f"A fatal JSON decoding error occurred -> {type(json_error).__name__}: {json_error}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue