tesla: Unable to refresh sso oauth token after restart my home assistant
Is there an existing issue for this?
- I have searched both the existing open issues & recently closed issues and did not find a duplicate of this issue.
I have read about the Fleet API and understand I may need to use it
- I understand issues relating to read only commands will be auto closed if not using the Fleet API.
Version of the Tesla component
3.20.5
Version of the Tesla car software
2024.8.9
Model
Model 3
Current Behavior
Everything works, but if I restart home assistant, the proxy launches fine but I have a disconnection alert and my entities linked to my vehicle no longer exist.
Expected Behavior
The token appears to still be valid. When I regenerate a token via the proxy and restart the configuration it works (but not necessarily on the first try)
Debug logs
2024-04-12 16:37:55.774 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-12 16:37:55.776 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration tesla_custom which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-04-12 16:37:59.856 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues
2024-04-12 16:38:32.025 WARNING (zeroconf-ServiceBrowser-_googlecast._tcp-111) [pychromecast.dial] Failed to determine cast type for host <unknown> (<urlopen error _ssl.c:983: The handshake operation timed out>) (services:{MDNSServiceInfo(name='Pioneer-VSX-832-2eed9b759085b44e4e932f09d32065f7._googlecast._tcp.local.')})
2024-04-12 16:41:14.128 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry florian@domain.com for tesla_custom
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tesla_custom/__init__.py", line 254, in async_setup_entry
cars = await controller.generate_car_objects(wake_if_asleep=wake_if_asleep)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 394, in generate_car_objects
self._vehicle_data[vin] = await self.get_vehicle_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 325, in get_vehicle_data
await self.api(
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1348, in api
await self.wake_up(car_id=car_id)
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 486, in wake_up
response = await self.get_vehicle_summary(vin=car_vin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 343, in get_vehicle_summary
await self.api(
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1375, in api
return await self.__post_with_retries_except_unavailable(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 314, in iter
return fut.result()
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/controller.py", line 1407, in __post_with_retries_except_unavailable
return await self.__connection.post(command, method=method, data=data, url=url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 166, in post
return await self.__open(url, method=method, headers=self.head, data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/teslajsonpy/connection.py", line 207, in __open
resp: httpx.Response = await getattr(self.websession, method)(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1801, in get
return await self.request(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1661, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1689, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1763, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 373, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request
raise exc from None
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 101, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 143, in handle_async_request
raise exc
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 113, in handle_async_request
) = await self._receive_response_headers(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 186, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_async/http11.py", line 224, in _receive_event
data = await self._network_stream.read(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 34, in read
return await self._stream.receive(max_bytes=max_bytes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anyio/streams/tls.py", line 205, in receive
data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anyio/streams/tls.py", line 147, in _call_sslobject_method
data = await self.transport_stream.receive()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1133, in receive
await self._protocol.read_event.wait()
File "/usr/local/lib/python3.12/asyncio/locks.py", line 212, in wait
await fut
asyncio.exceptions.CancelledError
2024-04-12 16:41:49.443 DEBUG (MainThread) [custom_components.tesla_custom.config_flow] Running in supervised environment
2024-04-12 16:41:49.542 DEBUG (MainThread) [custom_components.tesla_custom.config_flow] Found addon: c03d64a7_tesla_http_proxy
2024-04-12 16:41:57.596 DEBUG (MainThread) [custom_components.tesla_custom.config_flow] Credentials successfully connected to the Tesla API
2024-04-12 16:41:57.598 DEBUG (MainThread) [custom_components.tesla_custom] <ssl.SSLContext object at 0xffffb531dcd0>
2024-04-12 16:41:57.647 DEBUG (MainThread) [teslajsonpy.controller] 552 endpoints loaded
2024-04-12 16:41:57.648 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19826 days, 7:18:03
2024-04-12 16:41:57.648 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-04-12 16:41:57.649 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-04-12 16:41:57.982 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-04-12 16:41:57.983 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'Login required', 'referenceID': '4f3b29e2-f57b-4adb-8372-3bb683d235e6-1712932917851'}
2024-04-12 16:41:59.636 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19826 days, 7:18:01
2024-04-12 16:41:59.636 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-04-12 16:41:59.636 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-04-12 16:41:59.951 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-04-12 16:41:59.951 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'Login required', 'referenceID': '628612e4-d2a6-4351-90fa-6bb16fa5f689-1712932919841'}
2024-04-12 16:42:02.493 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19826 days, 7:17:58
2024-04-12 16:42:02.493 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-04-12 16:42:02.494 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-04-12 16:42:02.865 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-04-12 16:42:02.865 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'Login required', 'referenceID': '89f3a5aa-b7c2-4d18-b44d-9d54def24a81-1712932922689'}
2024-04-12 16:42:07.510 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19826 days, 7:17:53
2024-04-12 16:42:07.510 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-04-12 16:42:07.511 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-04-12 16:42:07.878 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-04-12 16:42:07.878 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'Login required', 'referenceID': 'fa866dd9-1e0b-47c0-a1ee-8b11a5b8d760-1712932927740'}
2024-04-12 16:42:12.650 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19826 days, 7:17:48
2024-04-12 16:42:12.651 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-04-12 16:42:12.651 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-04-12 16:42:13.156 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-04-12 16:42:13.156 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'Login required', 'referenceID': '865ca128-0871-4d97-aff5-3dd94d71a73b-1712932933046'}
2024-04-12 16:42:13.157 WARNING (MainThread) [homeassistant.config_entries] Config entry 'florian@domain.com' for tesla_custom integration could not authenticate
2024-04-12 16:42:20.364 DEBUG (MainThread) [custom_components.tesla_custom] <ssl.SSLContext object at 0xffffb531dcd0>
2024-04-12 16:42:20.414 DEBUG (MainThread) [teslajsonpy.controller] 552 endpoints loaded
2024-04-12 16:42:20.414 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19826 days, 7:17:40
2024-04-12 16:42:20.414 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-04-12 16:42:20.414 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-04-12 16:42:20.720 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-04-12 16:42:20.720 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'Login required', 'referenceID': '923151d9-18f6-4434-a632-d930b039879a-1712932940602'}
Anything else?
No response
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 17
Found a solution.
https://github.com/llamafilm/tesla-http-proxy-addon/discussions/111
You should use the token generated from het http proxy plugin not from somewhere else.
@craigrouse Thanks, I’ve managed to downgrade and it’s authenticating fine now. I may have to bump up a version to where support for the Fleet API was added, but at least for now I have the telemetry info.
It definitely smells like a bug in teslajsonpy given that it’s error messages are reporting tokens having expired around 19870 days ago (that’s over 50 years).