Closed Disciplus86 closed 1 month ago
Hi @Disciplus86,
Regrettably I don't own a cloud key. I will have to wait for someone else to help. You can investigate yourself as well. You can try changing the version value. I'm using the py-unifi library so you might be able to find relevant docs.
Thanks, J
Also, this is what chatgpt suggests :
The error you're encountering indicates that the login attempt to the UniFi Controller failed with a status code of 401, which typically means "Unauthorized." Here are some steps to troubleshoot:
Verify Credentials: Double-check the UNIFI_USERNAME and UNIFI_PASSWORD. Ensure there are no typos and that the account is active.
Check API Version: Ensure that the version specified (VERSION) is compatible with the UniFi Controller you are using.
SSL Verification: If you are using a self-signed certificate, you may need to set VERIFYSSL to False.
Site ID: Confirm that the site_id (in this case, SJ-UCK-1) is correct and that the user has permissions for that site.
Network Issues: Ensure that there are no firewall or network issues preventing the connection to the UniFi Controller.
Try these steps and see if the problem persists. If it does, please share any additional error messages or logs for further assistance.
I have a UDMP and have never been able to get the UniFi plugin working myself, always get a 401 error and have been meaning to open a dedicated issue for this.
In my case I’ve tried all 4 API versions, and only have a single default site.
Edit: Thanks for sharing the details about the underlying library, this issue helped solve my issue: https://github.com/finish06/pyunifi/issues/80
Thx @jokob-sk , the plugin pyunifi is on end of life i think. He have no update in 2 years. I have find a post for uck v2plus for put a protocol udmp_unifios. I will retry this protocol but i m not sur it will work... @nathang21 thx for you return I m sorry for my poor english and i will continue to fine a solution for my multi site unifi infra with 20 vlan. I have a vm with a unifi on a debian, if i have a same problem with this one, the problem will be global with pyunifi.
Also, this is what chatgpt suggests :
The error you're encountering indicates that the login attempt to the UniFi Controller failed with a status code of 401, which typically means "Unauthorized." Here are some steps to troubleshoot:
- Verify Credentials: Double-check the UNIFI_USERNAME and UNIFI_PASSWORD. Ensure there are no typos and that the account is active.
- Check API Version: Ensure that the version specified (VERSION) is compatible with the UniFi Controller you are using.
- SSL Verification: If you are using a self-signed certificate, you may need to set VERIFYSSL to False.
- Site ID: Confirm that the site_id (in this case, SJ-UCK-1) is correct and that the user has permissions for that site.
- Network Issues: Ensure that there are no firewall or network issues preventing the connection to the UniFi Controller.
Try these steps and see if the problem persists. If it does, please share any additional error messages or logs for further assistance.
Thx, but all this points have been verified.
Ok it's working ! Whis a UCK cloudkey V2 plus (firmware v4.0.18), the site will be "default" (Not the name of my site) and the protocol UDMP_unifiOS. It s resolve for me.
Hi @Disciplus86 ,
Glad to hear that!
Can you please post a screenshot of your settings so I can include the details into the docs?
Thanks in advance, j
no problem :
Hi @Disciplus86 ,
Thanks for that. I added a versions table to the docs to help others: https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/unifi_import
Is there an existing issue for this?
Current Behavior
Hello, I try to import from a UCK cloud key V2 plus and i have some error : 401 (login error). my user is on read only. netalertx is on a LXC docker on a proxmox in the last version.
On the cloud key V2 plus: UniFi OS v4.0.18 the https://IP/network/default/dashboard => work
i have try whis the site "default" => error 401 too
Please help!
Expected Behavior
i cant connect netalertx to unifi
Steps To Reproduce
No response
app.conf
No response
docker-compose.yml
No response
What branch are you running?
Production
app.log
17:52:01 [2024-10-14 17:52:01+02:00] START Run: UNFIMP 17:52:01 [Plugins] Resolving param: {'name': 'username', 'type': 'setting', 'value': 'UNFIMP_username'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: username 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'password', 'type': 'setting', 'value': 'UNFIMP_password'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [{'type': 'password'}], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [{'type': 'password'}], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: password 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'host', 'type': 'setting', 'value': 'UNFIMP_host'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: IP_OF_UCK 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'sites', 'type': 'setting', 'value': 'UNFIMP_sites'} 17:52:01 [Plugins] setTyp: {'dataType': 'array', 'elements': [{'elementType': 'input', 'elementOptions': [{'placeholder': 'Enter value'}, {'suffix': '_in'}, {'cssClasses': 'col-sm-10'}, {'prefillValue': 'null'}], 'transformers': []}, {'elementType': 'button', 'elementOptions': [{'sourceSuffixes': ['_in']}, {'separator': ''}, {'cssClasses': 'col-xs-12'}, {'onClick': 'addList(this, false)'}, {'getStringKey': 'Gen_Add'}], 'transformers': []}, {'elementType': 'select', 'elementHasInputValue': 1, 'elementOptions': [{'multiple': 'true'}, {'readonly': 'true'}, {'editable': 'true'}], 'transformers': []}, {'elementType': 'button', 'elementOptions': [{'sourceSuffixes': []}, {'separator': ''}, {'cssClasses': 'col-xs-6'}, {'onClick': 'removeAllOptions(this)'}, {'getStringKey': 'Gen_Remove_All'}], 'transformers': []}, {'elementType': 'button', 'elementOptions': [{'sourceSuffixes': []}, {'separator': ''}, {'cssClasses': 'col-xs-6'}, {'onClick': 'removeFromList(this)'}, {'getStringKey': 'Gen_Remove_Last'}], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'array', 'elements': [{'elementType': 'input', 'elementOptions': [{'placeholder': 'Enter value'}, {'suffix': '_in'}, {'cssClasses': 'col-sm-10'}, {'prefillValue': 'null'}], 'transformers': []}, {'elementType': 'button', 'elementOptions': [{'sourceSuffixes': ['_in']}, {'separator': ''}, {'cssClasses': 'col-xs-12'}, {'onClick': 'addList(this, false)'}, {'getStringKey': 'Gen_Add'}], 'transformers': []}, {'elementType': 'select', 'elementHasInputValue': 1, 'elementOptions': [{'multiple': 'true'}, {'readonly': 'true'}, {'editable': 'true'}], 'transformers': []}, {'elementType': 'button', 'elementOptions': [{'sourceSuffixes': []}, {'separator': ''}, {'cssClasses': 'col-xs-6'}, {'onClick': 'removeAllOptions(this)'}, {'getStringKey': 'Gen_Remove_All'}], 'transformers': []}, {'elementType': 'button', 'elementOptions': [{'sourceSuffixes': []}, {'separator': ''}, {'cssClasses': 'col-xs-6'}, {'onClick': 'removeFromList(this)'}, {'getStringKey': 'Gen_Remove_Last'}], 'transformers': []}]} 17:52:01 [Plugins] dType: array 17:52:01 [Plugin utils] Flattening the below array 17:52:01 ['SJ-UCK-1'] 17:52:01 [Plugin utils] isinstance(arr, list) : False | isinstance(arr, str) : True 17:52:01 [Plugins] Resolved value: SJ-UCK-1 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'port', 'type': 'setting', 'value': 'UNFIMP_port'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: 443 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'verifyssl', 'type': 'setting', 'value': 'UNFIMP_verifyssl'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'select', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'select', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: false 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'version', 'type': 'setting', 'value': 'UNFIMP_version'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'input', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: v4 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Resolving param: {'name': 'fullimport', 'type': 'setting', 'value': 'UNFIMP_fullimport'} 17:52:01 [Plugins] setTyp: {'dataType': 'string', 'elements': [{'elementType': 'select', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] setTypJSN: {'dataType': 'string', 'elements': [{'elementType': 'select', 'elementOptions': [], 'transformers': []}]} 17:52:01 [Plugins] dType: string 17:52:01 [Plugins] Resolved value: once 17:52:01 [Plugins] Convert to Base64: False 17:52:01 [Plugins] Timeout: 5 17:52:01 [Plugin utils] Pre-Resolved CMD: python3/app/front/plugins/unifi_import/script.py 17:52:01 [Plugins] Executing: python3 /app/front/plugins/unifi_import/script.py 17:52:01 [Plugins] Resolved : ['python3', '/app/front/plugins/unifi_import/script.py'] 17:52:02 [UNFIMP] In script 17:52:02 [UNFIMP] Full import NOT needed: config_value: once and lock_file_value: True 17:52:02 [UNFIMP] sites: ['SJ-UCK-1'] 17:52:02 [UNFIMP] site: SJ-UCK-1 17:52:02 /opt/venv/lib/python3.12/site-packages/urllib3/connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'IP_Unifi'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings warnings.warn( [plugin_helper] reading config file 17:52:02 [UNFIMP] In script 17:52:02 [UNFIMP] Full import NOT needed: config_value: once and lock_file_value: True 17:52:02 [UNFIMP] sites: ['SJ-UCK-1'] 17:52:02 [UNFIMP] site: SJ-UCK-1 Traceback (most recent call last): File "/app/front/plugins/unifi_import/script.py", line 286, in
main()
File "/app/front/plugins/unifi_import/script.py", line 63, in main
plugin_objects = get_entries(plugin_objects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/front/plugins/unifi_import/script.py", line 93, in get_entries
c = Controller(UNIFI_HOST, UNIFI_USERNAME, UNIFI_PASSWORD, port=PORT, version=VERSION, ssl_verify=VERIFYSSL, site_id=site)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.12/site-packages/pyunifi/controller.py", line 113, in init
self._login()
File "/opt/venv/lib/python3.12/site-packages/pyunifi/controller.py", line 195, in _login
raise APIError(
pyunifi.controller.APIError: Login failed - status code: 401
17:52:02 [Plugins] ⚠ ERROR - enable LOG_LEVEL=debug and check logs 17:52:02 [Plugins] No output received from the plugin "UNFIMP" 17:52:02 [2024-10-14 17:52:02+02:00] END Run: UNFIMP
Debug enabled