googleplay-api/test.py
Domenico Iezzi 2276f8db2c Changed login() behaviour
Previously, the ac2dm was meant to be saved in the application state, and later used for
subsequent logins, along with the gsfId. This is not correct, because the app needs it
only for the first login, and then remains unused in the application state.

The correct behaviour is to save the gsfId and the authSubToken, and provide only these two
values for subsequent logins

Signed-off-by: Domenico Iezzi <domenico.iezzi.201@gmail.com>
2017-10-04 11:32:56 +02:00

40 lines
1.1 KiB
Python

from gpapi.googleplay import GooglePlayAPI
import sys
EMAIL = "maracaiboez"
PASSWD = "fjgozwjmkwyvvutt"
testApps = ['com.cpuid.cpu_z']
server = GooglePlayAPI(debug=True)
try:
print('\nLogging in with email and password\n')
server.login(EMAIL, PASSWD, None, None)
gsfId = server.gsfId
authSubToken = server.authSubToken
print('\nNow trying secondary login with ac2dm token and gsfId saved\n')
server = GooglePlayAPI(debug=True)
server.login(None, None, gsfId, authSubToken)
apps = server.search('telegram', 1, None)
print('\nFound those apps:\n')
for a in apps:
print(a['docId'])
docid = apps[0]['docId']
version = apps[0]['versionCode']
print('\nTelegram docid is: %s\n' % docid)
print('\nAttempting to download %s\n' % docid)
fl = server.download(docid, version)
with open(docid + '.apk', 'wb') as f:
f.write(fl)
print('\nDownload successful\n')
f.close()
print('\nGetting details for %s\n' % testApps[0])
bulk = server.bulkDetails(testApps)
print(bulk)
except Exception as e:
print(str(e))
sys.exit(1)