mirror of
https://github.com/FliegendeWurst/googleplay-api.git
synced 2024-11-22 12:54:58 +00:00
parent
23937e6cb8
commit
c4ba7f80b3
@ -91,7 +91,16 @@ class DeviceBuilder(object):
|
|||||||
platform_v=self.device.get('build.version.release'),
|
platform_v=self.device.get('build.version.release'),
|
||||||
model=self.device.get('build.model'),
|
model=self.device.get('build.model'),
|
||||||
build_id=self.device.get('build.id'),
|
build_id=self.device.get('build.id'),
|
||||||
supported_abis=self.device.get('platforms'))
|
supported_abis=self.device.get('platforms').replace(',', ';'))
|
||||||
|
|
||||||
|
def getAuthHeaders(self, gsfid):
|
||||||
|
headers = {"User-Agent": ("GoogleAuth/1.4 ("
|
||||||
|
"{device} {id}"
|
||||||
|
")").format(device=self.device.get('build.device'),
|
||||||
|
id=self.device.get('build.id'))}
|
||||||
|
if gsfid is not None:
|
||||||
|
headers['device'] = "{0:x}".format(gsfid)
|
||||||
|
return headers
|
||||||
|
|
||||||
def getAuthParams(self, email, passwd):
|
def getAuthParams(self, email, passwd):
|
||||||
return {"Email": email,
|
return {"Email": email,
|
||||||
@ -105,9 +114,9 @@ class DeviceBuilder(object):
|
|||||||
"lang": self.locale,
|
"lang": self.locale,
|
||||||
"sdk_version": self.device['build.version.sdk_int']}
|
"sdk_version": self.device['build.version.sdk_int']}
|
||||||
|
|
||||||
def getLoginParams(self, email, encryptedPass):
|
def getLoginParams(self, email, encrypted_passwd):
|
||||||
return {"Email": email,
|
return {"Email": email,
|
||||||
"EncryptedPasswd": encryptedPass,
|
"EncryptedPasswd": encrypted_passwd,
|
||||||
"service": "ac2dm",
|
"service": "ac2dm",
|
||||||
"add_account": "1",
|
"add_account": "1",
|
||||||
"accountType": ACCOUNT,
|
"accountType": ACCOUNT,
|
||||||
@ -116,7 +125,7 @@ class DeviceBuilder(object):
|
|||||||
"source": "android",
|
"source": "android",
|
||||||
"device_country": self.locale[0:2],
|
"device_country": self.locale[0:2],
|
||||||
"lang": self.locale,
|
"lang": self.locale,
|
||||||
"sdk_version": self.device['build.version.sdk_int']}
|
"sdk_version": self.device.get('build.version.sdk_int')}
|
||||||
|
|
||||||
def getAndroidCheckinRequest(self):
|
def getAndroidCheckinRequest(self):
|
||||||
request = googleplay_pb2.AndroidCheckinRequest()
|
request = googleplay_pb2.AndroidCheckinRequest()
|
||||||
|
@ -196,7 +196,11 @@ class GooglePlayAPI(object):
|
|||||||
|
|
||||||
def getAuthSubToken(self, email, passwd):
|
def getAuthSubToken(self, email, passwd):
|
||||||
requestParams = self.deviceBuilder.getAuthParams(email, passwd)
|
requestParams = self.deviceBuilder.getAuthParams(email, passwd)
|
||||||
response = requests.post(self.AUTHURL, data=requestParams, verify=ssl_verify,
|
headers = self.deviceBuilder.getAuthHeaders(self.gsfId)
|
||||||
|
response = requests.post(self.AUTHURL,
|
||||||
|
data=requestParams,
|
||||||
|
verify=ssl_verify,
|
||||||
|
headers=headers,
|
||||||
proxies=self.proxies_config)
|
proxies=self.proxies_config)
|
||||||
data = response.text.split()
|
data = response.text.split()
|
||||||
params = {}
|
params = {}
|
||||||
@ -209,25 +213,27 @@ class GooglePlayAPI(object):
|
|||||||
firstToken = params["token"]
|
firstToken = params["token"]
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print('Master token: %s' % firstToken)
|
print('Master token: %s' % firstToken)
|
||||||
secondToken = self.getSecondRoundToken(requestParams, firstToken)
|
secondToken = self.getSecondRoundToken(firstToken, requestParams)
|
||||||
self.setAuthSubToken(secondToken)
|
self.setAuthSubToken(secondToken)
|
||||||
elif "error" in params:
|
elif "error" in params:
|
||||||
raise LoginError("server says: " + params["error"])
|
raise LoginError("server says: " + params["error"])
|
||||||
else:
|
else:
|
||||||
raise LoginError("Auth token not found.")
|
raise LoginError("auth token not found.")
|
||||||
|
|
||||||
def getSecondRoundToken(self, previousParams, firstToken):
|
def getSecondRoundToken(self, first_token, params):
|
||||||
previousParams['Token'] = firstToken
|
params['Token'] = first_token
|
||||||
previousParams['service'] = 'androidmarket'
|
params['service'] = 'androidmarket'
|
||||||
previousParams['check_email'] = '1'
|
params['check_email'] = '1'
|
||||||
previousParams['token_request_options'] = 'CAA4AQ=='
|
params['token_request_options'] = 'CAA4AQ=='
|
||||||
previousParams['system_partition'] = '1'
|
params['system_partition'] = '1'
|
||||||
previousParams['_opt_is_called_from_account_manager'] = '1'
|
params['_opt_is_called_from_account_manager'] = '1'
|
||||||
previousParams['google_play_services_version'] = '11518448'
|
params['google_play_services_version'] = '11518448'
|
||||||
previousParams.pop('Email')
|
params.pop('Email')
|
||||||
previousParams.pop('EncryptedPasswd')
|
params.pop('EncryptedPasswd')
|
||||||
|
headers = self.deviceBuilder.getAuthHeaders(self.gsfId)
|
||||||
response = requests.post(self.AUTHURL,
|
response = requests.post(self.AUTHURL,
|
||||||
data=previousParams,
|
data=params,
|
||||||
|
headers=headers,
|
||||||
verify=ssl_verify,
|
verify=ssl_verify,
|
||||||
proxies=self.proxies_config)
|
proxies=self.proxies_config)
|
||||||
data = response.text.split()
|
data = response.text.split()
|
||||||
@ -255,12 +261,15 @@ class GooglePlayAPI(object):
|
|||||||
|
|
||||||
url = self.FDFE + path
|
url = self.FDFE + path
|
||||||
if datapost is not None:
|
if datapost is not None:
|
||||||
response = requests.post(url, data=str(datapost),
|
response = requests.post(url,
|
||||||
headers=headers, verify=ssl_verify,
|
data=str(datapost),
|
||||||
|
headers=headers,
|
||||||
|
verify=ssl_verify,
|
||||||
timeout=60,
|
timeout=60,
|
||||||
proxies=self.proxies_config)
|
proxies=self.proxies_config)
|
||||||
else:
|
else:
|
||||||
response = requests.get(url, headers=headers,
|
response = requests.get(url,
|
||||||
|
headers=headers,
|
||||||
verify=ssl_verify,
|
verify=ssl_verify,
|
||||||
timeout=60,
|
timeout=60,
|
||||||
proxies=self.proxies_config)
|
proxies=self.proxies_config)
|
||||||
@ -326,7 +335,8 @@ class GooglePlayAPI(object):
|
|||||||
headers = self.getDefaultHeaders()
|
headers = self.getDefaultHeaders()
|
||||||
|
|
||||||
url = self.FDFE + path
|
url = self.FDFE + path
|
||||||
response = requests.get(url, headers=headers,
|
response = requests.get(url,
|
||||||
|
headers=headers,
|
||||||
verify=ssl_verify,
|
verify=ssl_verify,
|
||||||
timeout=60,
|
timeout=60,
|
||||||
proxies=self.proxies_config)
|
proxies=self.proxies_config)
|
||||||
@ -510,7 +520,7 @@ class GooglePlayAPI(object):
|
|||||||
|
|
||||||
if versionCode is None:
|
if versionCode is None:
|
||||||
# pick up latest version
|
# pick up latest version
|
||||||
versionCode = self.details(packageName)['versionCode']
|
versionCode = self.details(packageName).get('versionCode')
|
||||||
|
|
||||||
path = "delivery"
|
path = "delivery"
|
||||||
params = {'ot': str(offerType),
|
params = {'ot': str(offerType),
|
||||||
@ -577,7 +587,7 @@ class GooglePlayAPI(object):
|
|||||||
|
|
||||||
if versionCode is None:
|
if versionCode is None:
|
||||||
# pick up latest version
|
# pick up latest version
|
||||||
versionCode = self.details(packageName)['versionCode']
|
versionCode = self.details(packageName).get('versionCode')
|
||||||
|
|
||||||
path = "purchase"
|
path = "purchase"
|
||||||
headers = self.getDefaultHeaders()
|
headers = self.getDefaultHeaders()
|
||||||
|
Loading…
Reference in New Issue
Block a user