Open florianfish opened 2 months ago
I noticed as well on HA restart the integration fails claiming the token expired.
“ Authentication expired for ….@abc.xxx “
Reconfiguring with the same refresh token fixes the issue, it hasn’t expired.
Well after doing the reconfigure I mentioned above, somehow in the log this pops up:
2024-04-12 11:04:25.101 WARNING (MainThread) [homeassistant.config_entries] Config entry '...@abc.xxx' for tesla_custom integration could not authenticate
In the UI it shows Tesla Custom Integration -> Re-authentication was successful
Navigating to the Tesla integration, even if the above says successful there appears to be a problem:
The Re-authentication was successful
message in the UI cannot be trusted (since the Fleet API update). Something is wrong with the config flow code and I don’t know how to fix it.
I would like to kindly request a clarification on this. I have a 2018 MX, so I don't need the Fleet API, correct? At the same time there is an issue with the 3.20.x version that breaks the Owner API for my car. Is this also correct? If so, can I downgrade to 3.19.x to get things working again? If so, how do I do this? From what I can tell I can only downgrade to 3.20.2 or later. Thanks for any clarification.
For me it worked using the browser extension to get a new refresh token.
I am getting the same. It did work with old API but never worked with fleet API. When I set this up, the below is what I get:
`2024-05-10 15:56:08.927 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19854 days, 8:03:52
2024-05-10 15:56:08.927 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-05-10 15:56:08.927 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-05-10 15:56:09.735 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-05-10 15:56:09.735 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': 'aa3f3b29-3c3a-4303-ba79-951f81dd0125-1715320569583. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'} ` It does not matter how many times I get fresh refresh token, it is always the same. With expiration in nearly 20,000 days. Uninstall/reinstall/etc does not change it. I use iphone app to get token but the one obtained by add-on gave same result.
I have run in to this issue as well.
2024-05-26 21:26:09.658 DEBUG (MainThread) [teslajsonpy.connection] Successfully refreshed oauth
2024-05-26 21:26:09.658 DEBUG (MainThread) [teslajsonpy.connection] get: https://<hostname>:4430/api/1/products {}
2024-05-26 21:26:11.607 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 7:59:58
...
2024-05-26 21:26:29.671 DEBUG (MainThread) [teslajsonpy.controller] 552 endpoints loaded
2024-05-26 21:26:29.672 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in -19870 days, 2:33:31
2024-05-26 21:26:29.672 DEBUG (MainThread) [teslajsonpy.connection] Oauth expiration detected
2024-05-26 21:26:29.672 DEBUG (MainThread) [teslajsonpy.connection] Refreshing access token with refresh_token
2024-05-26 21:26:29.890 DEBUG (MainThread) [teslajsonpy.connection] Unable to refresh sso oauth token
2024-05-26 21:26:29.890 DEBUG (MainThread) [teslajsonpy.connection] Auth returned {'error': 'login_required', 'error_description': 'The refresh_token is invalid', 'referenceID': '31972244-7547-4273-ac31-55bf00327e42-1716776789821. For more information, visit: https://developer.tesla.com/docs/fleet-api#help-and-support'}
I wonder if it has to do with this token behavior change from Tesla back in February:
2024-02-01: Auth Access token policy change As part of a security improvement, the acquisition of a new Refresh token will now render the user’s previous Refresh token and its associated Access tokens invalid.
https://github.com/teslamotors/vehicle-command/issues/160
Discussion on this here - https://github.com/alandtse/tesla/discussions/918
I do have two "products" returned from the api/1/products
api call, a vehicle and a wall connector. I wonder if that is causing the double refresh.
I am experiencing this issue too, and my workaround was to switch back to the last known working version - 3.19.11. Every time a new version has been released, I've upgraded, and experienced the issue again, and rolled back. I couldn't see anything obvious in the code that might cause it, so perhaps it's an issue in the underlying python library - teslajsonpy? @alandtse do you have any ideas what might be causing this?
I'm getting the same issue. @craigrouse How does one install that older version? The redownload option in HACS doesn't go that far back.
@Lenbok go to releases on GitHub and download the zip file of that release. Take the contents of the file, and overwrite the files in the custom_components/tesla_custom directory. Restart HA and you'll be running the old version. It's easier to do this if you have the SMB add-on for HA so you can connect to it from another machine on your network. That said, I'm migrating to Teslemetry, which has a small cost, but is now a core HA component and uses the Tesla Fleet API without you having to host your own proxy. I'm impressed so far - everything works nicely.
@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).
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.
I should note that https://github.com/alandtse/tesla/issues/941#issuecomment-2132565548 is using the token generated from the temporary http proxy UI.
Suppose I should actually post here. I'm hitting this issue now. I don't know if it was today or yesterday, but the integration is reporting an issue with authentication. When I provide all of the required fleet info, I see Token expiration in -19910 days, 22:49:49
errors. I am using the refresh token provided by the http proxy.
As I mentioned above, I had the same, nothing helped, including downgrade, uninstalled it and watching here if anyone figures it out.
Is there an existing issue for this?
I have read about the Fleet API and understand I may need to use it
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
Anything else?
No response