You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mfa_token = input("Enter your 2FA Token: ")
c = Controller('-Unifi Controller-', '-username-', '-password-', mfa_token)
You also need to add token=0 to the start of the init definition, I put this after the password entry, then you'll need to define the self variable down further using self.token = token
Passing json in the session.post command was not sending in the correct format for this. it needs to be sent as data, and decoded from JSON. I have checked that this still does work with accounts without the 2FA enabled on it, you can either just not pass the 2FA argument, or send any value you like - it will be ignored.
Hope this helps those looking for an answer for this!
The text was updated successfully, but these errors were encountered:
Hi thanks for this - one of my controllers (UDM SE) does not ask for a MFA code each time I run the unmodified script, but my other controller (Unifi Express) fails to log in and I get the pop up on my unifi MFA app asking to approve login - which I do, but it obviously doesn't work.
I updated the file as you have above and installed it, but do not understand how to not put in the MFA code each time the script is run. Can you post an example? I'm just trying to run something basic like printing the connected client's IPs.
The following bit of code prompts you for your 6 digit code that gets generated by your authentication app:
mfa_token = input("Enter your 2FA Token: ")
Once you type in your code, the script will continue. This is how its setup from what I have written, as I do not have my accounts prompting for authentication prompts via the app - only though an authenticator app.
I have figured out what needs to be done for the 2FA changes that are coming into effect in July 22nd '24.
Here is the section of code I modified for the login to allow the passing of the 2FA token:
I pass this to the controller using this:
You also need to add
token=0
to the start of the init definition, I put this after the password entry, then you'll need to define the self variable down further usingself.token = token
Passing json in the session.post command was not sending in the correct format for this. it needs to be sent as data, and decoded from JSON. I have checked that this still does work with accounts without the 2FA enabled on it, you can either just not pass the 2FA argument, or send any value you like - it will be ignored.
Hope this helps those looking for an answer for this!
The text was updated successfully, but these errors were encountered: