Advertisement
Pouknouki

Untitled

Jul 28th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. import SteamLogin, SteamMobileAuth, pickle, SteamTradeOffers, SteamWebApi
  2.  
  3. def Login():
  4.    
  5.     print "Please log in to use this feature."
  6.     print "Username:"
  7.     username = raw_input()
  8.     print "Password:"
  9.     password = raw_input()
  10.  
  11.     details = {
  12.         "username":username,
  13.         "password":password,
  14.         # "shared_secret":"secret",
  15.     }
  16.    
  17.     try:
  18.        with open("Login.pickle") as f:
  19.            print "Loading existing session."
  20.            Login = pickle.load(f)
  21.            assert isinstance(Login, SteamLogin.SteamLogin), "Fuque."
  22.            Login.custom_url = Login._getCustomURL()
  23.            Login.steamID = Login._getSteamID()
  24.            print "OK."
  25.     except IOError:
  26.     # if True:
  27.         Login = SteamLogin.SteamLogin()
  28.         offset = SteamMobileAuth.getTimeOffset()
  29.         while True:
  30.             try:
  31.                 Login.login(details)
  32.                 break
  33.             except SteamLogin.TwoFactorCodeRequiredException:
  34.                 print("Enter your 2FA code.")
  35.                 details['twoFactorCode'] = raw_input()
  36.                 #details['twoFactorCode'] = SteamMobileAuth.generateAuthCode(details['shared_secret'],offset)
  37.             except SteamLogin.CaptchaRequiredException as e:
  38.                 print e
  39.                 details['captcha'] = raw_input()
  40.             except SteamLogin.EmailAuthException as e:
  41.                 print(e)
  42.             except SteamLogin.TooManyRequestsException as e:
  43.                 print "Retrying after " + e.retryafter+5 + " seconds"
  44.                 time.sleep(e.retryafter+5)
  45.             with open("Login.pickle",'wb') as f:
  46.                 print "Saving session to Login.picke"
  47.                 # pass #temporary until it works
  48.                 pickle.dump(Login,f)
  49.     return Login
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement