diff --git a/setup.py b/setup.py index 51dba878..80734573 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ VERSION = None # What packages are required for this module to be executed? -REQUIRED = ["aiohttp", "backoff", "wrapt"] +REQUIRED = ["aiohttp", "backoff", "bs4", "wrapt"] # What packages are optional? EXTRAS = { diff --git a/teslajsonpy/connection.py b/teslajsonpy/connection.py index b9c64bd0..9143b141 100644 --- a/teslajsonpy/connection.py +++ b/teslajsonpy/connection.py @@ -216,7 +216,7 @@ async def __open( f'{data.get("error")}:{data.get("error_description")}' ) except aiohttp.ClientResponseError as exception_: - raise TeslaException(exception_.status) + raise TeslaException(exception_.status) from exception_ return data async def websocket_connect(self, vin: int, vehicle_id: int, **kwargs): @@ -434,10 +434,10 @@ async def refresh_access_token(self, refresh_token): "refresh_token": refresh_token, "scope": "openid email offline_access", } - auth = await self.__open( - "/oauth2/v3/token", "post", data=oauth, baseurl="https://auth.tesla.com", + auth = await self.websession.post( + "https://auth.tesla.com/oauth2/v3/token", data=oauth, ) - return auth + return await auth.json() async def get_bearer_token(self, access_token): """Get bearer token. This is used by the owners API."""