Upload login.py
Browse files
login.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from twttrapi import TwttrAPIClient
|
2 |
+
from getpass import getpass
|
3 |
+
|
4 |
+
api_key = "your_rapidapi_key_here"
|
5 |
+
client = TwttrAPIClient(api_key)
|
6 |
+
|
7 |
+
username = input("Username/Email: ")
|
8 |
+
password = getpass()
|
9 |
+
|
10 |
+
r = client.login_email_username(username, password)
|
11 |
+
|
12 |
+
if "success" in r and r["success"] == True:
|
13 |
+
print("Session: " + r["session"])
|
14 |
+
|
15 |
+
else:
|
16 |
+
if "errors" in r:
|
17 |
+
print("Error: " + r["errors"][0]["message"])
|
18 |
+
|
19 |
+
elif "login_data" in r:
|
20 |
+
while True:
|
21 |
+
login_data = r["login_data"]
|
22 |
+
resp = getpass(r["message"] + ": ")
|
23 |
+
|
24 |
+
r = client.login_2fa(login_data, resp)
|
25 |
+
|
26 |
+
if "login_data" in r:
|
27 |
+
pass
|
28 |
+
|
29 |
+
elif r["success"] == True:
|
30 |
+
print("Session: " + r["session"])
|
31 |
+
break
|
32 |
+
|
33 |
+
else:
|
34 |
+
print("Error: " + r["error"])
|
35 |
+
break
|
36 |
+
|
37 |
+
else:
|
38 |
+
print("Error: Can't login.")
|
39 |
+
|
40 |
+
|