Unifi Integration Invalid Authentication

Hello, what am I missing? My set up is as follows:

Home Assistant core-2021.5.1 installed in a Docker container running on an Ubuntu 20.04 server (I’ve been trying for a couple of months).

Unifi Controller is installed in a Docker container running on a separate Ubuntu 20.04 server.

I have an EdgeRouter X that is my DHCP server that the Unifi Controller sees - I can control the EdgeRouter X from the Unifi Controller.

The issue I have is that I’m trying to add the Ubiquiti Unifi integration to Home Assistant: for the host name, I put in the IP address of the Ubuntu server that has the Unifi Controller running on it. For the username and password, I enter credentials that I’ve created locally on the Unifi Controller. I leave the SSL box unchecked. The message I receive is “invalid authentication.”

What have I tried?

Have used different username and password combinations.
Removed and re-installed docker and Unifi Controller.
Installed Unifi Controller on a different server.
These all give the Invalid authentication error.

I’ve also tried connecting via a different port and using a server that doesn’t have the Unifi Controller installed - these both gave “Failed to connect.”

I cannot see any error messages in any log files relating to authentication, either at Ubuntu OS level or within the Unifi Controller.

I’m all out of ideas, can anyone help, please?

Thanks. Laurie.

3 Likes

So I have found something under Configuration / General / Logs.

Logger: homeassistant.components.unifi
Source: components/unifi/controller.py:493
Integration: Ubiquiti UniFi ([documentation](https://www.home-assistant.io/integrations/unifi), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+unifi%22))
First occurred: 8 May 2021, 02:28:36 (6 occurrences)
Last logged: 02:03:47

Unknown UniFi communication error occurred: Call https://192.168.1.241:443/api/login received 404 Not Found

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/unifi/controller.py", line 493, in get_controller await controller.login() File "/usr/local/lib/python3.8/site-packages/aiounifi/controller.py", line 108, in login await self._request("post", url=url, json=auth) File "/usr/local/lib/python3.8/site-packages/aiounifi/controller.py", line 288, in _request raise ResponseError(f"Call {url} received 404 Not Found") aiounifi.errors.ResponseError: Call https://192.168.1.241:443/api/login received 404 Not Found

192.168.1.241 is the server that the Unifi Controller is installed on.

Yes, I have the same - started when either I updated to HomeAssistant 2020.5.0, or UniFiOS 2.1.7 or UniFi Network 6.1.71

Unknown UniFi communication error occurred: Call https://192.168.1.xxx:8443 received 404 Not Found
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/unifi/controller.py", line 492, in get_controller
    await controller.check_unifi_os()
  File "/usr/local/lib/python3.8/site-packages/aiounifi/controller.py", line 91, in check_unifi_os
    response = await self._request("get", url=self.url, allow_redirects=False)
  File "/usr/local/lib/python3.8/site-packages/aiounifi/controller.py", line 288, in _request
    raise ResponseError(f"Call {url} received 404 Not Found")
aiounifi.errors.ResponseError: Call https://192.168.1.xxx:8443 received 404 Not Found

I didn’t upgrade HA but did upgrade Unifi network to 6.1.71 and my integration is no longer working as well. Also running new 2.1.71 on controller. Tried removing and re-adding it but it just says authentication failed.

+1 waiting for a fix

Yep, I can confirm that upgrading my unifi controller to 6.2.26 triggered this issue for me also. Looking at my logs, the authentication fails because 2FA is required for my account.

Logger: homeassistant.components.unifi
Source: components/unifi/controller.py:493
Integration: Ubiquiti UniFi (documentation, issues)
First occurred: 4:52:45 PM (1 occurrences)
Last logged: 4:52:45 PM

Unknown UniFi communication error occurred: api.err.Ubic2faTokenRequired
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/unifi/controller.py", line 493, in get_controller
    await controller.login()
  File "/usr/local/lib/python3.9/site-packages/aiounifi/controller.py", line 108, in login
    await self._request("post", url=url, json=auth)
  File "/usr/local/lib/python3.9/site-packages/aiounifi/controller.py", line 300, in _request
    _raise_on_error(response)
  File "/usr/local/lib/python3.9/site-packages/aiounifi/controller.py", line 318, in _raise_on_error
    raise_error(data["meta"]["msg"])
  File "/usr/local/lib/python3.9/site-packages/aiounifi/errors.py", line 57, in raise_error
    raise cls("{}".format(type))
aiounifi.errors.TwoFaTokenRequired: api.err.Ubic2faTokenRequired

Disabling 2FA (here) allowed my integration to work again. I hope 2FA support can be added soon!

Create a local administrator account for use with the integration and then you can keep 2FA on your remote accounts.
https://help.ui.com/hc/en-us/articles/1500011491541-UniFi-Manage-users-and-user-roles.

I do not have 2FA and am also getting the 404 error

Any update on this, I’m getting the exact thing… hopefully something fixed in the last 2 years!
Thanks!

HA:
Home Assistant 2023.8.4
Supervisor 2023.08.1
Operating System 10.5
Frontend 20230802.1 - latest

Cloud Key: 7.2.97-18705-1

Yes, I created a local user.

I have the same issue

My unfit is at 192.168.1.1

I have a local user

I have tried port 443,7443 and 8443

Nothing works. I don’t know why this integration is so difficult to login to!

8443
Error connecting to the UniFi Network at 192.186.1.1:

15:49:29 – (ERROR) unifi - message first occurred at 10:54:18 and shows up 4 times

7443

Connected to UniFi Network at 192.168.1.1 but login required: Call https://192.168.1.1:7443/api/login received 401 Unauthorized

15:50:41 – (WARNING) unifi - message first occurred at 11:51:32 and shows up 5 times

443

Unknown UniFi Network communication error occurred: Call https://192.168.1.1:443/api/auth/login received 403 Forbidden

15:51:42 – (ERROR) unifi - message first occurred at 10:54:30 and shows up 4 times

The login is correct - I goto 192.168.1.1 I get the login screen and I can login.

I cant get the Dream Machine to send emails so the user is showing as Pending - but it works to login so I cant see this as being the issue.

If anyone has any suggestions I would appreciate it

1 Like

Can anyone help ?

Im seeing this error as well. It was 2FA causing my issue. My IP address changed, so I had to change the IP exclusion in my SWAG docket by adding the new IP address to the internal.conf file.

Emails? Pending? I’m not sure what you’re talking about there, but I’m guessing you created a cloud user instead of a local user. You need to use a LOCAL user account.