I have tried to design the API so that existing code and control flow is not broken by this change.
If 2fa is not set up, this basic example will work as expected:
from edupage_api import Edupage
edupage = Edupage()
try:
edupage.login("Username", "Password", "Your school's subdomain")
except BadCredentialsException:
print("Wrong username or password!")
except LoginDataParsingException:
print("Try again or open an issue!")
You have successfully logged in.
If 2fa is set up, you can login in a similar way — note the second_factor variable:
from edupage_api import Edupage
edupage = Edupage()
try:
second_factor = edupage.login("Username", "Password", "Your school's subdomain")
# or
second_factor = edupage.login_auto("Username", "Password")
except BadCredentialsException:
print("Wrong username or password!")
except LoginDataParsingException:
print("Try again or open an issue!")
This will return the TwoFactorLogin object, which can be used to complete the login, or to resend the 2fa notification.
There are two ways to complete the login process:
By confirming through the mobile application:
while not second_factor.is_confirmed():
time.sleep(0.5)
second_factor.finish()
# You are now logged in!
By confirming the code (from email or mobile app):
second_factor.finish_with_code("123456")
# You are now logged in!
I have tried to design the API so that existing code and control flow is not broken by this change.
If 2fa is not set up, this basic example will work as expected:
You have successfully logged in.
If 2fa is set up, you can login in a similar way — note the
second_factor
variable:This will return the
TwoFactorLogin
object, which can be used to complete the login, or to resend the 2fa notification.There are two ways to complete the login process:
By confirming through the mobile application:
By confirming the code (from email or mobile app):