From 9cf52f6f58dec011a73b45fc658cb0d620787d26 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 2 Aug 2016 16:50:21 +0200 Subject: [PATCH] fix login bug --- pokemongo_bot/__init__.py | 8 ++++---- pokemongo_bot/api_wrapper.py | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 2d9d4a6ad3..b075223ddf 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -256,13 +256,13 @@ def is_numeric(s): def login(self): logger.log('Attempting login to Pokemon Go.', 'white') - self.api.reset_auth() lat, lng = self.position[0:2] self.api.set_position(lat, lng, 0) - while not self.api.login(self.config.auth_service, - str(self.config.username), - str(self.config.password)): + while not self.api.login( + self.config.auth_service, + str(self.config.username), + str(self.config.password)): logger.log('[X] Login Error, server busy', 'red') logger.log('[X] Waiting 10 seconds to try again', 'red') diff --git a/pokemongo_bot/api_wrapper.py b/pokemongo_bot/api_wrapper.py index 2235ac41de..8510b6d79a 100644 --- a/pokemongo_bot/api_wrapper.py +++ b/pokemongo_bot/api_wrapper.py @@ -1,7 +1,6 @@ import time from pgoapi.exceptions import NotLoggedInException, ServerBusyOrOfflineException, NoPlayerPositionSetException, EmptySubrequestChainException - from pgoapi.pgoapi import PGoApi, PGoApiRequest, RpcApi from POGOProtos.Networking.Requests_pb2 import RequestType @@ -19,10 +18,19 @@ def create_request(self): ) return request - def reset_auth(self): - self._auth_token = None - self._auth_provider = None - self._api_endpoint = None + def create_vanilla_request(self): + return PGoApi.create_request(self) + + def login(self, *args): + # login needs base class "create_request" + old_request = self.create_request + self.create_request = self.create_vanilla_request + try: + ret_value = PGoApi.login(self, *args) + finally: + # cleanup code + self.create_request = old_request + return ret_value class ApiRequest(PGoApiRequest):