Browse Source

Added session_id in WebAuth

pull/60/head
kostyan0013 9 years ago
parent
commit
e81772b6b0
  1. 23
      steam/webauth.py

23
steam/webauth.py

@ -79,6 +79,7 @@ class WebAuth(object):
session = None #: :class:`requests.Session` (with auth cookies after auth is complete)
captcha_gid = -1
steam_id = None #: :class:`.SteamID` (after auth is complete)
_session_id = None
def __init__(self, username, password):
self.__dict__.update(locals())
@ -118,6 +119,23 @@ class WebAuth(object):
return resp
@property
def session_id(self):
if self._session_id:
return self._session_id
try:
headers = {
'X-Requested-With': 'com.valvesoftware.android.steam.community'}
self.session.get('https://steamcommunity.com/login',
params={'oauth_client_id': 'DE45CD61',
'oauth_scope': 'read_profile write_profile read_client write_client'
},
headers=headers, timeout=15)
except requests.exceptions.RequestException as e:
raise HTTPError(str(e))
self._session_id = self.session.cookies['sessionid']
return self._session_id
def _load_key(self):
if not self.key:
resp = self.get_rsa_key(self.username)
@ -251,17 +269,22 @@ class MobileWebAuth(WebAuth):
class WebAuthException(Exception):
pass
class HTTPError(WebAuthException):
pass
class LoginIncorrect(WebAuthException):
pass
class CaptchaRequired(WebAuthException):
pass
class EmailCodeRequired(WebAuthException):
pass
class TwoFactorCodeRequired(WebAuthException):
pass

Loading…
Cancel
Save