From 2739270600fbc45242d3c1ba8de5e1a8cf0251c1 Mon Sep 17 00:00:00 2001 From: detiam <44510779+detiam@users.noreply.github.com> Date: Fri, 8 Nov 2024 06:22:21 +0800 Subject: [PATCH] fix(webauth): handle InvalidPassword error in _startSessionWithCredentials (#6) --- steam/webauth.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/steam/webauth.py b/steam/webauth.py index 2179344f..e2fa4480 100644 --- a/steam/webauth.py +++ b/steam/webauth.py @@ -59,6 +59,7 @@ from getpass import getpass import requests +from steam.enums.common import EResult from steam.enums.proto import EAuthSessionGuardType, EAuthTokenPlatformType, ESessionPersistence from steam.steamid import SteamID from steam.utils.web import generate_session_id @@ -208,10 +209,16 @@ def _startSessionWithCredentials(self, account_encrypted_password: str, 'BeginAuthSessionViaCredentials', 1 ) - self.client_id = resp['response']['client_id'] - self.request_id = resp['response']['request_id'] - self.steam_id = SteamID(resp['response']['steamid']) - self.allowed_confirmations = [EAuthSessionGuardType(confirm_type['confirmation_type']) for confirm_type in resp['response']['allowed_confirmations']] + try: + self.client_id = resp['response']['client_id'] + self.request_id = resp['response']['request_id'] + self.steam_id = SteamID(resp['response']['steamid']) + self.allowed_confirmations = [EAuthSessionGuardType(confirm_type['confirmation_type']) for confirm_type in resp['response']['allowed_confirmations']] + except KeyError as e: + if resp.get('response', {}).get('interval') == EResult.InvalidPassword: + raise LoginIncorrect(resp) + else: + raise WebAuthException(e, resp) def _startLoginSession(self): """Starts login session via credentials."""