oauth
This commit is contained in:
parent
9107e00bb2
commit
dd7f82ee0b
1 changed files with 68 additions and 52 deletions
54
app.py
54
app.py
|
@ -9,37 +9,48 @@ from os import environ
|
|||
import imaplib
|
||||
import email
|
||||
from time import sleep
|
||||
|
||||
# get previously known message ids from imap server
|
||||
|
||||
print('loggin into IMAP Server:', environ['IMAP_HOST'])
|
||||
|
||||
Mailbox = imaplib.IMAP4_SSL(environ['IMAP_HOST'])
|
||||
Mailbox.login(environ['IMAP_USER'], environ['IMAP_PASSWORD'])
|
||||
Mailbox.select()
|
||||
typ, data = Mailbox.search(None, '(FROM "noreply@steampowered.com" SUBJECT "Your Steam account: Access from new web or mobile device")')
|
||||
old_msg_ids = data[0].split()
|
||||
|
||||
# perform steam login
|
||||
from os import path
|
||||
|
||||
print('loggin into STEAM:', environ['STEAM_USERNAME'])
|
||||
user = wa.MobileWebAuth(environ['STEAM_USERNAME'])
|
||||
|
||||
user = wa.WebAuth(environ['STEAM_USERNAME'])
|
||||
|
||||
# try oauth token
|
||||
try:
|
||||
print('trying oauth login')
|
||||
|
||||
with open('oauth_token', 'r') as file:
|
||||
user.oauth_login(file.read(), steam_id=environ['STEAM_ID'], language='english')
|
||||
|
||||
print('oauth login successful')
|
||||
except (wa.LoginIncorrect, FileNotFoundError) as exp:
|
||||
print('oauth login failed:', exp)
|
||||
|
||||
# get previously known message ids from imap server
|
||||
|
||||
print('loggin into IMAP Server:', environ['IMAP_HOST'])
|
||||
|
||||
Mailbox = imaplib.IMAP4_SSL(environ['IMAP_HOST'])
|
||||
Mailbox.login(environ['IMAP_USER'], environ['IMAP_PASSWORD'])
|
||||
Mailbox.select()
|
||||
typ, data = Mailbox.search(None, '(FROM "noreply@steampowered.com" SUBJECT "Your Steam account: Access from new web or mobile device")')
|
||||
old_msg_ids = data[0].split()
|
||||
|
||||
# perform steam login
|
||||
|
||||
try:
|
||||
user.login(environ['STEAM_PASSWORD'])
|
||||
except (wa.LoginIncorrect) as exp:
|
||||
except (wa.LoginIncorrect) as exp:
|
||||
print('ERROR: loggin incorrect')
|
||||
raise
|
||||
except (wa.CaptchaRequired) as exp:
|
||||
except (wa.CaptchaRequired) as exp:
|
||||
print('ERROR: captcha required:', user.captcha_url)
|
||||
#user.login(password=environ['STEAM_PASSWORD'], captcha=input("Captcha: "))
|
||||
raise
|
||||
except wa.TwoFactorCodeRequired:
|
||||
except wa.TwoFactorCodeRequired:
|
||||
print('ERROR: 2FA code required')
|
||||
#user.login(twofactor_code=input("2FA Code: "))
|
||||
raise
|
||||
except wa.EmailCodeRequired:
|
||||
except wa.EmailCodeRequired:
|
||||
print('getting email code')
|
||||
while True:
|
||||
typ, data = Mailbox.search(None, '(FROM "noreply@steampowered.com" SUBJECT "Your Steam account: Access from new web or mobile device")')
|
||||
|
@ -65,7 +76,12 @@ except wa.EmailCodeRequired:
|
|||
break
|
||||
|
||||
print('code found:', code)
|
||||
user.login(email_code=code)
|
||||
user.login(email_code=code, language='english')
|
||||
|
||||
with open('oauth_token', 'w') as file:
|
||||
file.write(user.oauth_token)
|
||||
|
||||
print('password login successful')
|
||||
|
||||
# CRAWL
|
||||
|
||||
|
|
Loading…
Reference in a new issue