Build request params with current device data

Login and Auth parameters are built using device selected in
deviceBuilder object. Also got rid of an unused parameter client_sig.
This commit is contained in:
Domenico Iezzi 2017-10-19 17:51:03 +02:00
parent dd2d7b64d1
commit 5034244620
2 changed files with 28 additions and 29 deletions

View File

@ -14,6 +14,7 @@ DFE_TARGETS = "CAEScFfqlIEG6gUYogFWrAISK1WDAg+hAZoCDgIU1gYEOIACFkLMAeQBnASLATlAS
LANG = "en_US"
TIMEZONE = 'America/New_York'
GOOGLE_PUBKEY = "AAAAgMom/1a/v0lblO2Ubrt60J2gcuXSljGFQXgcyZWveWLEwo6prwgi3iJIZdodyhKZQrNWp5nKJ3srRXcUW+F1BD3baEVGcmEgqaLZUNBjm057pKRI16kB0YppeGx5qIQ5QjKzsR8ETQbKLNWgRY0QRNVz34kMJR3P/LgHax/6rmf5AAAAAwEAAQ=="
ACCOUNT = "HOSTED_OR_GOOGLE"
# parse phone config from the file 'device.properties'.
# if you want to add another phone, just create another section in
@ -65,6 +66,31 @@ class DeviceBuilder(object):
hardware=self.device['build.hardware'],
product=self.device['build.product'])
def getAuthParams(self, email, passwd):
return {"Email": email,
"EncryptedPasswd": passwd,
"accountType": ACCOUNT,
"has_permission": "1",
"source": "android",
"device_country": LANG[0:2],
"service": "androidmarket",
"app": "com.android.vending",
"lang": LANG,
"sdk_version": self.device['build.version.sdk_int']}
def getLoginParams(self, email, encryptedPass):
return {"Email": email,
"EncryptedPasswd": encryptedPass,
"service": "ac2dm",
"add_account": "1",
"accountType": ACCOUNT,
"has_permission": "1",
"app": "com.google.android.gsf",
"source": "android",
"device_country": LANG[0:2],
"lang": LANG,
"sdk_version": self.device['build.version.sdk_int']}
def getAndroidCheckinRequest(self):
request = googleplay_pb2.AndroidCheckinRequest()
request.id = 0

View File

@ -44,12 +44,10 @@ class GooglePlayAPI(object):
SEARCHURL = FDFE + "search"
CHECKINURL = BASE + "checkin"
AUTHURL = BASE + "auth"
ACCOUNT = "HOSTED_OR_GOOGLE"
def __init__(self, debug=False, device_codename='bacon'):
self.authSubToken = None
self.gsfId = None
self.lang = config.LANG
self.debug = debug
self.deviceBuilder = config.DeviceBuilder(device_codename)
@ -152,20 +150,7 @@ class GooglePlayAPI(object):
encryptedPass = self.encrypt_password(email, password).decode('utf-8')
# AC2DM token
params = {
"Email": email,
"EncryptedPasswd": encryptedPass,
"service": "ac2dm",
"add_account": "1",
"accountType": self.ACCOUNT,
"has_permission": "1",
"app": "com.google.android.gsf",
"source": "android",
"device_country": "en",
"lang": self.lang,
"sdk_version": "25",
"client_sig": "38918a453d07199354f8b19af05ec6562ced5788"
}
params = self.deviceBuilder.getLoginParams(email, encryptedPass)
response = requests.post(self.AUTHURL, data=params, verify=ssl_verify)
data = response.text.split()
params = {}
@ -202,19 +187,7 @@ class GooglePlayAPI(object):
raise LoginError('Either (email,pass) or (gsfId, authSubToken) is needed')
def getAuthSubToken(self, email, passwd):
params = {
"Email": email,
"EncryptedPasswd": passwd,
"accountType": self.ACCOUNT,
"has_permission": "1",
"source": "android",
"device_country": "en",
"service": "androidmarket",
"app": "com.android.vending",
"lang": self.lang,
"sdk_version": "25",
"client_sig": "38918a453d07199354f8b19af05ec6562ced5788"
}
params = self.deviceBuilder.getAuthParams(email, passwd)
response = requests.post(self.AUTHURL, data=params, verify=ssl_verify)
data = response.text.split()
params = {}