SecKatie / wyzeapy

36 stars 26 forks source link

2fa #16

Closed JoeSchubert closed 3 years ago

JoeSchubert commented 3 years ago

I believe that this 2fa functionality should help. However, the best I could come up with is that the functionality for calling/creating this had to change. Basically, instead of just calling create()... that needs to be called, then login and login_with_2fa if the exception is raised. I think this will give a decent way of catching the existence of 2fa in the config flow for Home Assistant as well to be able to display an additional interface to get the 2fa code.

I included an example in the commit. But I'll also include it here:

async def async_main(): client = await Wyzeapy.create() try: await client.login("username", "password") except TwoFactorAuthenticationEnabled: await client.login_with_2fa(input("Enter 2fa code:")) finally: print("Got a token!")

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

JoeSchubert commented 3 years ago

Change bca6971 will allow for passing a token back to the external caller using this library. I'm not sure the best way to send the token back and forth though to an external caller. Perhaps just make another function that should be called after the login/login_with_2fa functions? Should we return the token at the end of these calls and just let the caller deal with it?