Open jonepet opened 1 month ago
I just checked and mine at 5}
on the end. Removed it and reloaded and everything started working again.
I'm trying to look into this issue, from first glance I see correct usage of the functions to read/write the token file. However, in the read_token, I see a retry mechanism that is trying to re-authenticate, which can rewrite the token file and retry reading it.
Could you provide the full corrupt token file (so I can try to reproduce in test code) or debugging logs? I am wondering if the line "Fixing malformed token" is in there...
I'm trying to look into this issue, from first glance I see correct usage of the functions to read/write the token file. However, in the read_token, I see a retry mechanism that is trying to re-authenticate, which can rewrite the token file and retry reading it.
Could you provide the full corrupt token file (so I can try to reproduce in test code) or debugging logs? I am wondering if the line "Fixing malformed token" is in there...
I'll turn on debugging for the app and keep tabs the next few days.
I was running into this as well... First time after authenticating it works, after it tries to reauthenticate, it fails with an extra }
Before I found this issue, I just reauthenticated and it worked again... for a day or 2, now deleting the } fixes it as well.. I just enabled debugging as well for wehn it happens next time
So I had the error again and did not seem to have fixing malformed token in the logs.... do have this stuff in logs:
`
2024-08-12 07:29:49.374 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'fordpass' calls async_forward_entry_setup for integration, fordpass with title: 2017 Ford Fusion (removed) and entry_id: removed, which is deprecated and will stop working in Home Assistant 2025.6, await async_forward_entry_setups instead at custom_components/fordpass/init.py, line 83: hass.async_create_task(, please create a bug report at https://github.com/itchannel/fordpass-ha/issues
2024-08-12 07:30:06.264 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration fordpass with title: 2017 Ford Fusion Energi (removed) and entry_id: removed, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.
Stack (most recent call last):
File "
2024-08-12 22:34:01.940 WARNING (SyncWorker_52) [urllib3.connectionpool] Retrying (Retry(total=5, connect=3, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1000)'))': /v1.0/endpoint/default/authorize?redirect_uri=fordapp://userauthorized&response_type=code&scope=openid&max_age=3600&client_id=removed&code_challenge=removed&code_challenge_method=S256
2024-08-12 22:34:04.097 ERROR (MainThread) [custom_components.spook] Unexpected exception from <function AbstractSpookRepair.async_activate.
2024-08-12 22:34:10.870 ERROR (MainThread) [custom_components.fordpass] Error fetching fordpass data: Error communicating with FordPass for removed 2024-08-12 22:34:10.875 WARNING (MainThread) [custom_components.fordpass] 2024-08-12 22:34:10.876 WARNING (MainThread) [custom_components.fordpass] Error communicating with FordPass for removed 2024-08-12 22:34:10.876 ERROR (MainThread) [custom_components.fordpass] Error fetching fordpass data: Error communicating with FordPass for removed `
Actually I restarted HA like 5 times in a row and ended up with both the extra } and the last character, so I had to delete the last 2 characters to get it working again.
The first 4 errors are because of API changes on Home Assistant side, and was acually already reported in issue #520 and resolved with pull request #521, so updating your data to the latest 1.70 branch state will resolve these errors.
Unfortunately I can't make sense of the last error at this moment.
The @_fordpass_token.txt file often gets corupted with an additional } at the end occationally, at least a couple of times a month. Trying to figure out if this is common, or if this is a local file system issue on my system. Symptom is sensors becomes unavailable and setup fails after failing to refresh token. Temporary solution is always to remove the additional } at the end and save the file.
I cannot find any reason in the code for this, my theory has been that it happens if there is less characters when re-writing file than before, and it does not clear the file, but as far as I can see this should not happen.
Anyone else seeing this issue, or is it just me? This is on the 1.70 beta branch
{"access_token": "...", "refresh_token": "...", "expires_in": 1800, "refresh_expires_in": 31556952, "expiry_date": 1720862042.6590693, "auto_token": "...", "auto_refresh": "....", "auto_expiry": 1720860542.326344}}
Should be:
{"access_token": "...", "refresh_token": "...", "expires_in": 1800, "refresh_expires_in": 31556952, "expiry_date": 1720862042.6590693, "auto_token": "...", "auto_refresh": "....", "auto_expiry": 1720860542.326344}