mirror of
https://github.com/vladkens/twscrape.git
synced 2026-10-30 15:08:09 -04:00
login flow improvements
This commit is contained in:
1 parent
5a3f7c19a6
commit
ef76b5de84
2 files changed
+3
-5
No files matched your search
+1
-2
@@ -98,10 +98,9 @@ async def imap_login(email: str, password: str):
|
||||
|
||||
try:
|
||||
imap.login(email, password)
|
||||
imap.select("INBOX", readonly=True)
|
||||
except imaplib.IMAP4.error as e:
|
||||
logger.error(f"Error logging into {email} on {domain}: {e}")
|
||||
imap.select("INBOX")
|
||||
imap.close()
|
||||
raise EmailLoginError() from e
|
||||
|
||||
return imap
|
||||
+2
-3
@@ -11,7 +11,7 @@ from .utils import raise_for_status, utc
|
||||
|
||||
async def get_guest_token(client: AsyncClient):
|
||||
rep = await client.post("https://api.twitter.com/1.1/guest/activate.json")
|
||||
raise_for_status(rep, "guest_token")
|
||||
raise_for_status(rep, "guest_token (most likely ip ban)")
|
||||
return rep.json()["guest_token"]
|
||||
|
||||
|
||||
@@ -189,10 +189,9 @@ async def login(acc: Account, email_first=False) -> Account:
|
||||
logger.info(f"account already active {log_id}")
|
||||
return acc
|
||||
|
||||
imap = None
|
||||
if email_first:
|
||||
imap = await imap_login(acc.email, acc.email_password)
|
||||
else:
|
||||
imap = None
|
||||
|
||||
client = acc.make_client()
|
||||
guest_token = await get_guest_token(client)
|
||||
|
||||
Reference in new issue
Block a user