diff --git a/etc/twcmanager/config.json b/etc/twcmanager/config.json index 11f71c49..1692170c 100644 --- a/etc/twcmanager/config.json +++ b/etc/twcmanager/config.json @@ -155,6 +155,9 @@ # # Only set "httpProxyCert" when setting "teslaApiUrl" to a local proxy. #"httpProxyCert": "/path/to/public_key.pem", + # + # Only set "teslaApiClientID" when setting "teslaApiUrl" to a local proxy. + #"teslaApiClientID": "client-id-of-proxy", # The cloudUpdateInterval determines how often to poll certain # data retrieved from the Tesla API to evaluate policy. diff --git a/lib/TWCManager/Vehicle/TeslaAPI.py b/lib/TWCManager/Vehicle/TeslaAPI.py index 2c769da3..a8a9fa11 100644 --- a/lib/TWCManager/Vehicle/TeslaAPI.py +++ b/lib/TWCManager/Vehicle/TeslaAPI.py @@ -19,6 +19,7 @@ class TeslaAPI: __authURL = "https://auth.tesla.com/oauth2/v3/token" __callbackURL = "https://auth.tesla.com/void/callback" baseURL = "https://owner-api.teslamotors.com/api/1/vehicles" + refreshClientID = "ownerapi" proxyCert = None carApiLastErrorTime = 0 carApiBearerToken = "" @@ -64,6 +65,7 @@ def __init__(self, master): try: self.config = master.config self.baseURL = self.config["config"].get("teslaApiUrl", "https://owner-api.teslamotors.com/api/1/vehicles") + self.refreshClientID = self.config["config"].get("teslaApiClientID", "ownerapi") self.proxyCert = self.config["config"].get("httpProxyCert", None) self.minChargeLevel = self.config["config"].get("minChargeLevel", -1) self.chargeUpdateInterval = self.config["config"].get( @@ -108,10 +110,9 @@ def apiRefresh(self): # days when first issued, so we'll get a new token every 15 days. headers = {"accept": "application/json", "Content-Type": "application/json"} data = { - "client_id": "ownerapi", + "client_id": self.refreshClientID, "grant_type": "refresh_token", "refresh_token": self.getCarApiRefreshToken(), - "scope": "openid email offline_access", } req = None now = time.time()