-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtwo_factor_auth.py
34 lines (28 loc) · 925 Bytes
/
two_factor_auth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from sys import argv
from pyotp import TOTP
from context import Instpector, endpoints
def get_profile(**options):
instpector = Instpector()
# Using pyotp for getting the two-factor authentication code
totp = TOTP(options.get("two_factor_key"))
if not instpector.login(user=options.get("user"),
password=options.get("password"),
two_factor_code=totp.now()):
return
profile = endpoints.factory.create("profile", instpector)
print(profile.of_user("target_user_name"))
instpector.logout()
if __name__ == '__main__':
if len(argv) < 6:
print((
"Missing arguments: "
"--user {user} "
"--password {password} "
"--two_factor_key {two_factor_key}"
))
exit(1)
get_profile(
user=argv[2],
password=argv[4],
two_factor_key=argv[6]
)