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
评论列表
文章目录