forked from peter/volvo2mqtt
Add more logging for refresh process // renew refresh token if returned from api
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name: "Volvo2Mqtt"
|
name: "Volvo2Mqtt"
|
||||||
description: "Volvo AAOS MQTT bridge"
|
description: "Volvo AAOS MQTT bridge"
|
||||||
version: "1.12.1"
|
version: "1.12.2"
|
||||||
slug: "volvo2mqtt"
|
slug: "volvo2mqtt"
|
||||||
init: false
|
init: false
|
||||||
url: "https://github.com/Dielee/volvo2mqtt"
|
url: "https://github.com/Dielee/volvo2mqtt"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
from config import settings
|
from config import settings
|
||||||
|
|
||||||
VERSION = "v1.12.1"
|
VERSION = "v1.12.2"
|
||||||
|
|
||||||
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
OAUTH_TOKEN_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
||||||
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
|
OAUTH_AUTH_URL = "https://volvoid.eu.volvocars.com/as/authorization.oauth2"
|
||||||
|
|||||||
+9
-7
@@ -175,8 +175,9 @@ def send_otp(auth_session, data):
|
|||||||
|
|
||||||
|
|
||||||
def refresh_auth():
|
def refresh_auth():
|
||||||
logging.info("Refreshing credentials")
|
|
||||||
global refresh_token
|
global refresh_token
|
||||||
|
logging.info("Refreshing credentials with token " + refresh_token)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"authorization": "Basic aDRZZjBiOlU4WWtTYlZsNnh3c2c1WVFxWmZyZ1ZtSWFEcGhPc3kxUENhVXNpY1F0bzNUUjVrd2FKc2U0QVpkZ2ZJZmNMeXc=",
|
"authorization": "Basic aDRZZjBiOlU4WWtTYlZsNnh3c2c1WVFxWmZyZ1ZtSWFEcGhPc3kxUENhVXNpY1F0bzNUUjVrd2FKc2U0QVpkZ2ZJZmNMeXc=",
|
||||||
"content-type": "application/x-www-form-urlencoded",
|
"content-type": "application/x-www-form-urlencoded",
|
||||||
@@ -198,12 +199,13 @@ def refresh_auth():
|
|||||||
token_path = util.get_token_path()
|
token_path = util.get_token_path()
|
||||||
refresh_data = auth.json()
|
refresh_data = auth.json()
|
||||||
|
|
||||||
f = open(token_path)
|
if not "refresh_token" in refresh_data:
|
||||||
try:
|
f = open(token_path)
|
||||||
data = json.load(f)
|
try:
|
||||||
refresh_token = data["refresh_token"]
|
data = json.load(f)
|
||||||
except ValueError:
|
refresh_token = data["refresh_token"]
|
||||||
raise Exception("Cannot refresh token!")
|
except ValueError:
|
||||||
|
raise Exception("Cannot refresh token!")
|
||||||
|
|
||||||
refresh_data["refresh_token"] = refresh_token
|
refresh_data["refresh_token"] = refresh_token
|
||||||
util.save_to_json(refresh_data, token_path)
|
util.save_to_json(refresh_data, token_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user