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
+4
View File
@@ -40,9 +40,13 @@ def authorize(renew_tokenfile=False):
if os.path.isfile(token_path) and not renew_tokenfile: if os.path.isfile(token_path) and not renew_tokenfile:
logging.info("Using login from token file") logging.info("Using login from token file")
f = open(token_path) f = open(token_path)
try:
data = json.load(f) data = json.load(f)
refresh_token = data["refresh_token"] refresh_token = data["refresh_token"]
refresh_auth() refresh_auth()
except ValueError:
logging.warning("Dected corrupted token file, restarting auth process")
authorize(True)
else: else:
logging.info("Starting login with OTP") logging.info("Starting login with OTP")
auth_session = requests.session() auth_session = requests.session()