I was seeing the exact same errors that the OP. Also, my Lovelace left-hand menu was missing all my Add-ons and the ‘Add-Ons’ menu missing from the Settings page.
My homeassistant.log file would show this entry over and over:
2023-02-09 23:27:58.394 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from supervisor (172.30.32.2). Requested URL: '/auth/token'. (HomeAssistantSupervisor/2023.01.1 aiohttp/3.8.3 Python/3.10)
Running ha supervisor logs
from the terminal would display a lot of these errors:
23-02-09 23:23:37 ERROR (MainThread) [supervisor.homeassistant.api] Can't update Home Assistant access token!
23-02-09 23:23:37 ERROR (MainThread) [supervisor.homeassistant.api] Can't update Home Assistant access token!
23-02-09 23:23:37 ERROR (MainThread) [supervisor.homeassistant.api] Can't update Home Assistant access token!
I tried rebooting, waited 48 hours, still not working. I tried running all the ha commands I could. None resolved my problem.
# ha core rebuild
Error: Unknown error, see supervisor
# ha authentication cache
Command completed successfully.
# ha supervisor repair
Command completed successfully.
This issue appeared after a power bump and HASS did not cleanly shutdown.
I spent a few hours searching online but I could not find what was wrong. I kept on digging, started looking at the supervisor python code and discoveredthat the supervisor lost it’s homeassistant refresh_token.
The refresh_token is property in /mnt/data/supervisor/homeassistant.json that allows the Supervisor to communicate with HomeAssistant. As you can see below, there is no refresh_token property:
# cat /mnt/data/supervisor/homeassistant.json
{
"ssl": false,
"audio_input": null,
"audio_output": null,
"boot": true,
"watchdog": true,
"uuid": "e1263b5c50c5030c67a8441b282c8840 ",
"port": 8123,
"version": "2023.1.7",
"image": "ghcr.io/home-assistant/qemux86-64-homeassistant"
}
To fix this, I had to locate the Supervisor’s refresh_token from the homeassistant auth database and add it to the supervisor configuration file, homeassistant.json.
Here’s how I did it:
# cd /mnt/data/supervisor/
# # First make a backup of the current file, just in case.
# cp homeassistant.json homeassistant.json.backup
# # Extract the Supervisor userid from the homeassistant auth database.
# export sup_id=$(cat homeassistant/.storage/auth | jq -r '.data.users[] | select(.name == "Supervisor") | .id'); echo $sup_id
8f7e53535353c88d
# # Next extract the refresh_token value for the Supervisor account
# export sub_token=$(cat homeassistant/.storage/auth | jq -r '.data.refresh_tokens[] | select(.user_id == env.sup_id) | .token'); echo $sub_token
4640dc8a2069799e00c1ebcd046241e6ec9d82053dd0ddab141ad98e65866bcaf00085bf37f563b0496a1c50267b23df7a73bff1efe6857951f3daeb2138cf39
# # Now add this token to a temporary Supervisor configuration file.
# cat homeassistant.json | jq '. += {"refresh_token": env.sub_token }' | tee homeassistant.json.with_token
{
"ssl": false,
"audio_input": null,
"audio_output": null,
"boot": true,
"watchdog": true,
"uuid": "e1263b5c50c5030c67a8441b282c8840 ",
"port": 8123,
"version": "2023.1.7",
"image": "ghcr.io/home-assistant/qemux86-64-homeassistant",
"refresh_token": "4640dc8a2069799e00c1ebcd046241e6ec9d82053dd0ddab141ad98e65866bcaf00085bf37f563b0496a1c50267b23df7a73bff1efe6857951f3daeb2138cf39"
}
# # Finally, you have to stop the supervisor before replacing the config file. Give it enough time before moving on.
# docker stop hassio_supervisor
# mv homeassistant.json.with_token homeassistant.json
# docker start hassio_supervisor
# sleep 30
# # Rebuild core to fix and sync up everything again.
# ha core rebuild
Command completed successfully.
I reloaded my Lovelace UI and everything worked!.