Take care of corrupted token files #220

This commit is contained in:
Linus Dietz
2024-08-09 08:25:17 +02:00
parent 17eaa8dde2
commit f23f56e45e
+7 -3
View File
@@ -40,9 +40,13 @@ def authorize(renew_tokenfile=False):
if os.path.isfile(token_path) and not renew_tokenfile:
logging.info("Using login from token file")
f = open(token_path)
data = json.load(f)
refresh_token = data["refresh_token"]
refresh_auth()
try:
data = json.load(f)
refresh_token = data["refresh_token"]
refresh_auth()
except ValueError:
logging.warning("Dected corrupted token file, restarting auth process")
authorize(True)
else:
logging.info("Starting login with OTP")
auth_session = requests.session()