-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from ivanhrabcak/feature/2fa
Implement support for 2fa (Closes #74)
- Loading branch information
Showing
4 changed files
with
217 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import time | ||
from edupage_api import Edupage | ||
from edupage_api.exceptions import SecondFactorFailedException, BadCredentialsException | ||
|
||
edupage = Edupage() | ||
|
||
USERNAME = "Username" | ||
PASSWORD = "Password" | ||
SUBDOMAIN = "Your school's subdomain" | ||
|
||
try: | ||
second_factor = edupage.login(USERNAME, PASSWORD, SUBDOMAIN) | ||
confirmation_method = input( | ||
"Choose confirmation method: 1 -> mobile app, 2 -> code: " | ||
) | ||
|
||
if confirmation_method == "1": | ||
while not second_factor.is_confirmed(): | ||
time.sleep(0.5) | ||
second_factor.finish() | ||
|
||
elif confirmation_method == "2": | ||
code = input("Enter 2FA code (or 'resend' to resend the code): ") | ||
while code.lower() == "resend": | ||
second_factor.resend_notifications() | ||
code = input("Enter 2FA code (or 'resend' to resend the code): ") | ||
second_factor.finish_with_code(code) | ||
|
||
except BadCredentialsException: | ||
print("Wrong username or password") | ||
except SecondFactorFailedException: | ||
print("Second factor failed") | ||
|
||
if edupage.is_logged_in: | ||
print("Logged in") | ||
else: | ||
print("Login failed") |