Skip to content

Commit

Permalink
Build request params with current device data
Browse files Browse the repository at this point in the history
Login and Auth parameters are built using device selected in
deviceBuilder object. Also got rid of an unused parameter client_sig.
  • Loading branch information
Domenico Iezzi committed Oct 19, 2017
1 parent dd2d7b6 commit 5034244
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
26 changes: 26 additions & 0 deletions gpapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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
Expand Down Expand Up @@ -65,6 +66,31 @@ def getUserAgent(self):
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
Expand Down
31 changes: 2 additions & 29 deletions gpapi/googleplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -152,20 +150,7 @@ def login(self, email=None, password=None, gsfId=None, authSubToken=None):

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 = {}
Expand Down Expand Up @@ -202,19 +187,7 @@ def login(self, email=None, password=None, gsfId=None, authSubToken=None):
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 = {}
Expand Down

0 comments on commit 5034244

Please sign in to comment.