mirror of
https://github.com/Dielee/volvo2mqtt.git
synced 2026-08-13 11:19:52 +02:00
Take care of corrupted token files #220
This commit is contained in:
+7
-3
@@ -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)
|
||||||
data = json.load(f)
|
try:
|
||||||
refresh_token = data["refresh_token"]
|
data = json.load(f)
|
||||||
refresh_auth()
|
refresh_token = data["refresh_token"]
|
||||||
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user