Long Lived Access Token - 403 Forbidden


I am attempting to get a Long-Lived Access token to work appdaemon. For me, this is resulting in:

WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds

in the appdaemon logs.

After digging a bit deeper, I have tried the following on the same machine as home assistant:

curl -v -X GET http://<my_ip>:8123/api/error/all -H "Authorization: Bearer potato"

As expected, this returns:

Authorization: Bearer potato
HTTP/1.1 403 Forbidden

I then tried my real token from my secrets file:

curl -v -X GET http://<my_ip>:8123/api/error/all -H "Authorization: Bearer $(grep appdaemon_ll_token secrets.yaml | awk -F': ' ' { print $2 } ') "

This returns:

Authorization: Bearer <expected_token>
HTTP/1.1 403 Forbidden

To generate this token:

  1. I logged into an existing user account for appdaemon on HA,
  2. Navigated to /profile,
  3. Clicked on long-lived tokens -> create token,
  4. Created it with a simple name,
  5. Copied the token into my secrets file so appdaemon can see it.

It seems clear that the token is being read from the secrets file correctly (see the curl above), and that token matches what I copied from the field after creating the token. What am I doing wrong?

  • Ben

Replying to myself since I found a fix…this was caused by http/ip_ban_enabled. Too many attempts to setup up the long-lived access token got my local IP banned. Removing myself from ip_bans.yaml fixed the 403 Forbidden issue, and it’s now working.