UniFi - 401 Unauthorized

Receiving the following error when using the following - Unauthorized - Connecting to Unifi network I’m using an admin user


      - type: custom:slider-button-card
        entity: switch.haileys_fire_tv
        slider:
          direction: left-right
          background: solid
          use_state_color: false
          use_percentage_bg_opacity: false
          show_track: false
          toggle_on_click: true
          force_square: false
          show_attribute: false
        show_name: true
        show_state: true
        compact: true
        icon:
          show: true
          use_state_color: true
          tap_action:
            action: more-info
          icon: ''
        action_button:
          mode: toggle
          icon: mdi:power
          show: true
          show_spinner: true
          tap_action:
            action: toggle

image

I’m running in the the same exact error.

I’m using a Unifi Local Super Admin for credentials on Home Assistant.

I rolled back several versions of Home Assistant and still have this issue so it must be the Unifi 4.0.6 (OS) firmware that might be causing this problem.

It could be related to their enforcement of MFA . They should have started enforcing it in 10 days’ time according to the emails I’ve been getting. I wouldn’t be surprised they rolled it out slightly earlier:

EDIT: This only affects UI cloud accounts. See @fleskefjes clarification below.

MFA does not affect local users, which is what you need to use with the integration. The mandatory MFA is only for the UI accounts (cloud accounts). https://community.ui.com/questions/Upcoming-Multi-Factor-Authentication-MFA-Requirement-for-All-UI-Accounts-in-July-2024/e0d06d3c-c0ae-4af6-aa67-53c159d486a8

1 Like

Oh, missed that, thanks!

1 Like

I was already using a local user but I’m still receiving this 401 and am unable to reconfigure (even after deletion and readding of the local user) the Integration

You create the user on the OS settings, right? not the SSH settings? I did the same error once.
image

I did create the admin user locally, yes
Even given the user a pre-defined with only read-rights (also tried it with full admin rights)

Same problem, local users, tons of 401 unauthorized when trying to re-add integration… Must be a Unifi OS update as mine auto-updates.

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