UniFi - 401 Unauthorized

Same issue with 401 authentication error when trying switch clients or portforwarding rules off and on. No issue adding integration.

Need some help getting this fixed.

Also running into this issue, tried new user, only local, both view only on network and superadmin for the user, to no avail

Same issue for me with local user only and only read rights.
Tried:

  • restarted the Unifi console/ controller and HA
  • removed the integration and re-added it with a new Unifi local user (could not re-add the integration with the previous user)
  • made sure SSL is not checked in the integration
  • am only using Unifi Network application
  • My UniFi OS version is 4.0.6
  • Home Assistant 2024.8.0

You who still have issues; what UniFi gateway are you running?

Am using the relatively new Cloud Gateway Max.
Thanks for looking into this man and the integration. Its great :slight_smile:

Ok, then you have this issue Authentication error 429/421 with controls but status sensors are working · Issue #122438 · home-assistant/core · GitHub

We’re trying to figure out what the difference is when doing a toggle on the UniFi app and through the integration.

Thank Robban, I looked through the linked GitHub thread and the issue seem to be with HA toggle not acting the same way as using the button in the browser UI directly hence causing this issue. Interestingly, I see the same logs on more or less the same hardware (gateway ultra vs max) but I only use a local “READ” only admin account for UniFi. I only intend to read values hence did I not create and entities to control directly from HA. Ill test what happens if I use an admin account.

Edit: just tested with Unifi rights Full Management for both OS and Network and same warning shows in the logs. Ill Continue in Github thread to keep this a bit more clean here :slight_smile:

I’m seeing this in the logs

Logger: homeassistant.components.unifi
Source: components/unifi/hub/entity_loader.py:94
integration: UniFi Network (documentation, issues)
First occurred: 8:52:11 AM (93 occurrences)
Last logged: 9:07:31 AM

Exception on update Call https://192.168.7.1:443/api/auth/login received 429: b’{“code”:“AUTHENTICATION_FAILED_LIMIT_REACHED”,“message”:“You've reached the login attempt limit”,“level”:“debug”}’
Exception on update Call https://192.168.7.1:443/proxy/network/v2/api/site/default/trafficrules received 401 Unauthorized

Yes its all detailed in UniFi - 401 Unauthorized - #15 by Robban

I have a cloud key gen2+

The issue has been resolved and a fix is out with 2024.8.2 release, the cause was a new type of cookie metadata not yet supported in python

1 Like

Great job!

I cant really take any Credit. Rsvi had hinted to the change in the unifi protect integration that solved the issue. I just copied it

Hey unfortunately this exact same error seems to have returned on HA 2024.12.0. Anyone else experiencing this error?

2 Likes

Yes, I have been getting this error since updating to 2024.12.0.
Sensors seem to be working.
I can’t see an option in the settings to reconfigure the user login.

Same failure for me on an Cloud Gateway Ultra
Completely deleted the unifi integration and restarted everything - still same error.
Sensors work - but all switches dont

Can you replicate this error?
@Robban

Same error here after last update. Swiches are not working anymore

I will check, I remember someone saying that the expected fix in the new python 3.13 wouldn’t get merged in time, and the fix in the library does not take effect on python 3.13 because it where supposed to be fixed

Thank, a fix would be appreaciated. I reverted back the update and now it works fine again.

Fix has been merged and targets 2024.12.2 release