Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix steam_guard passing and case login after passing login_cookies #294

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions steampy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, api_key: str, username: str = None, password: str = None, ste
self.set_proxies(proxies)
self.steam_guard_string = steam_guard
if self.steam_guard_string is not None:
self.steam_guard = guard.load_steam_guard(self.steam_guard)
self.steam_guard = guard.load_steam_guard(self.steam_guard_string)
else:
self.steam_guard = None
self.was_login_executed = False
Expand Down Expand Up @@ -64,19 +64,21 @@ def get_steam_id(self) -> int:
raise ValueError('Invalid steam_id: {}'.format(steam_id))

def login(self, username: str = None, password: str = None, steam_guard: str = None) -> None:
if self.was_login_executed and self.is_session_alive():
# session is alive, no need login again
return

if None in [self.username, self._password, self.steam_guard_string] and None in [username, password, steam_guard]:
raise InvalidCredentials('You have to pass username, password and steam_guard'
'parameters when using "login" method')

if None in [self.username, self._password, self.steam_guard_string]:
self.steam_guard_string = steam_guard
self.steam_guard = guard.load_steam_guard(steam_guard)
self.steam_guard = guard.load_steam_guard(self.steam_guard_string)
self.username = username
self._password = password

if self.was_login_executed and self.is_session_alive():
# session is alive, no need login again
return

self._session.cookies.set("steamRememberLogin", 'true')
LoginExecutor(self.username, self._password, self.steam_guard['shared_secret'], self._session).login()
self.was_login_executed = True
Expand Down