ValueError: Error in authentication

I’m really struggling here.
I’m running HA 0.93.1 on UnRAID as a docker container. I have Node-Red for automations, and letsencrypt for WAN access. It all works great.

I decided to make a move into AppDaemon, but cannot for the LIFE of me get it to work. This is also running via docker.

The error I get with the debug flag set is “ValueError: Error in authentication.” It repeatedly reports it has connected to HA, then disconnects.

2019-05-23 21:39:48.040626 INFO AppDaemon: HASS: Connected to Home Assistant 0.93.1
2019-05-23 21:39:48.043252 WARNING AppDaemon: HASS: Error in authentication

2019-05-23 21:39:48.043353 DEBUG AppDaemon: Event type:ha_disconnected:
2019-05-23 21:39:48.043438 DEBUG AppDaemon: {}
2019-05-23 21:39:48.043568 WARNING AppDaemon: HASS: Disconnected from Home Assistant, retrying in 5 seconds

2019-05-23 21:39:48.043638 WARNING AppDaemon: HASS: ------------------------------------------------------------

2019-05-23 21:39:48.043739 WARNING AppDaemon: HASS: Unexpected error:

2019-05-23 21:39:48.043807 WARNING AppDaemon: HASS: ------------------------------------------------------------

2019-05-23 21:39:48.044011 WARNING AppDaemon: HASS: Traceback (most recent call last):

File "/usr/local/lib/python3.6/site-packages/appdaemon/plugins/hass/hassplugin.py", line 181, in get_updates
raise ValueError("Error in authentication")

ValueError: Error in authentication

My Home Assistant configuration looks like this:

  auth_providers:
   - type: homeassistant
   - type: legacy_api_password
     api_password: !secret http_password
   - type: trusted_networks
     trusted_networks:
      - 192.168.254.0/24
      - 127.0.0.1
      - ::1
      - fd00::/8

And the API password is set, because I can use it to login, on the IP address & port provided to AppDaemon.

I have no idea what is wrong.
The only idea I have is that it may be related to my baseurl being set to my external URL for the sake of the letsencrypt, but I’ve tried connecting AppDaemon via the external address (which I can use to call the API successfully from other apps like Tasker) too, and that doesn’t work either. I’ve had a variety of 403 and 502 errors. I’ve also turned off IP bans whilst I’m debugging this, because the AppDaemon instance kept banning itself due to ‘incorrect auth.’

Can you please post your appdaemon.yaml configuration file? Also, you should generate and use a long-lived access token instead of the legacy api password.

Sure;

log:
  logfile: STDOUT
  errorfile: STDERR
appdaemon:
  threads: 10
  plugins:
HASS:
  type: hass
  ha_url: http://192.168.254.210:8123
  token: <redacted>
hadashboard:
  dash_url: http://$HOSTNAME:5050

I’ll give that a go, thanks.
Edit: nope, tried generating an access token and using that instead of my API password. Still no dice. Same error as before. HASS reports the following in its logs:

2019-05-24 16:35:18 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 192.168.254.210

Just to make sure, does it look like this:

log:
  logfile: STDOUT
  errorfile: STDERR
appdaemon:
  threads: 10
  plugins:
    HASS:
      type: hass
      ha_url: http://192.168.254.210:8123
      token: <redacted>
hadashboard:
  dash_url: http://$HOSTNAME:5050

or like you showed:

log:
  logfile: STDOUT
  errorfile: STDERR
appdaemon:
  threads: 10
  plugins:
HASS:
  type: hass
  ha_url: http://192.168.254.210:8123
  token: <redacted>
hadashboard:
  dash_url: http://$HOSTNAME:5050

The one I posted was copied directly from the YAML. It seems to be generated by the docker container; any changes get overwritten when I restart the container.

Edit: Thanks so much, you’ve helped me figure out what was wrong. The API token was not valid auth in this situation; the long-lived auth token was. But it was getting overwritten by the docker configuration. I’ve edited my docker setup to use the auth token instead, and everything works. Thanks!