Skip to content

Commit

Permalink
fix login bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DayBr3ak committed Aug 2, 2016
1 parent 26f6087 commit 9cf52f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
18 changes: 13 additions & 5 deletions pokemongo_bot/api_wrapper.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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):
Expand Down

0 comments on commit 9cf52f6

Please sign in to comment.