def login(self, provider, username, password): # login needs base class "create_request" self.useVanillaRequest = True if self.config.check_niantic_api is True: capi = '0.45.0' link = "https://pgorelease.nianticlabs.com/plfe/version" f = urllib.urlopen(link) myfile = f.read() self.config.check_niantic_api print "Niantic Official API Version:" + myfile if capi not in myfile: print( "\033[1;31;40m We have detected a Pokemon API Change. The current API version 0.45.0 is no longer supported. Exiting..." ) sys.exit(1) try: PGoApi.set_authentication(self, provider, username=username, password=password) except: raise response = PGoApi.app_simulation_login(self) # cleanup code self.useVanillaRequest = False return response
def api_init(account): api = PGoApi() try: api.set_position(360,360,0) api.set_authentication(provider = account.auth_service, username = account.username, password = account.password) api.activate_signature(get_encryption_lib_path()); time.sleep(1); api.get_player() except AuthException: log.error('Login for %s:%s failed - wrong credentials?' % (account.username, account.password)) return None else: time.sleep(1); response = api.get_inventory() if response: if 'status_code' in response: if response['status_code'] == 1 or response['status_code'] == 2: return api elif response['status_code'] == 3: # try to accept ToS time.sleep(5); response = api.mark_tutorial_complete(tutorials_completed = 0, send_marketing_emails = False, send_push_notifications = False) if response['status_code'] == 1 or response['status_code'] == 2: print('Accepted TOS for %s' % account.username) return api elif response['status_code'] == 3: print('Account %s BANNED!' % account.username) raise AccountBannedException return None
def login(self, provider, username, password): # login needs base class "create_request" self.useVanillaRequest = True if self.config.check_niantic_api is True: capi = '0.45.0' link = "https://pgorelease.nianticlabs.com/plfe/version" f = urllib.urlopen(link) myfile = f.read() self.config.check_niantic_api print "Niantic Official API Version:" + myfile if capi not in myfile: print("\033[1;31;40m We have detected a Pokemon API Change. The current API version 0.45.0 is no longer supported. Exiting...") sys.exit(1) try: PGoApi.set_authentication( self, provider, username=username, password=password ) except: raise response = PGoApi.app_simulation_login(self) # cleanup code self.useVanillaRequest = False return response
def login(self, provider, username, password): # login needs base class "create_request" self.useVanillaRequest = True # Get Timecode and Country Code country_code = "US" timezone = "America/Chicago" geolocator = GoogleV3(api_key=self.config.gmapkey) if self.config.locale_by_location: try: location = geolocator.reverse((self.actual_lat, self.actual_lng), timeout = 10, exactly_one=True) country_code = self.get_component(location,'country') except: self.logger.warning("Please make sure you have google api key and enable Google Maps Geocoding API at console.developers.google.com") try: timezone = geolocator.timezone([self.actual_lat, self.actual_lng], timeout=10) except: self.logger.warning("Please make sure you have google api key and enable Google Maps Time Zone API at console.developers.google.com") # Start login process try: if self.config.proxy: PGoApi.set_authentication( self, provider, username=username, password=password, proxy_config={'http': self.config.proxy, 'https': self.config.proxy} ) else: PGoApi.set_authentication( self, provider, username=username, password=password ) except: raise try: if self.config.locale_by_location: response = PGoApi.app_simulation_login(self,country_code,timezone.zone) else: response = PGoApi.app_simulation_login(self) # To prevent user who have not update the api being caught off guard by errors except BadHashRequestException: self.logger.warning("Your hashkey seems to have expired or is not accepted!") self.logger.warning("Please set a valid hash key in your auth JSON file!") exit(-3) raise except BannedAccountException: self.logger.warning("This account is banned!") exit(-3) raise except: raise # cleanup code self.useVanillaRequest = False return response
def login(self, provider, username, password): # login needs base class "create_request" self.useVanillaRequest = True try: PGoApi.set_authentication(self, provider, username=username, password=password) except: raise response = PGoApi.app_simulation_login(self) # cleanup code self.useVanillaRequest = False return response
def login(self, provider, username, password): # login needs base class "create_request" self.useVanillaRequest = True try: PGoApi.set_authentication( self, provider, username=username, password=password ) except: raise response = PGoApi.app_simulation_login(self) # cleanup code self.useVanillaRequest = False return response