-
-
Notifications
You must be signed in to change notification settings - Fork 25
How-to docs #3
Comments
Just a short example here, I think you can find out the rest by trying :)
Now you should have a valid and running dfeclient. Depending on your setup, the AndroidContext and the UserAgent might be different
And some possible interesting helper methods:
Note: The things above are untested, but might work. As you might have seen my last commit is more than half a year ago and things might have changed. This API is far from complete yet - and maybe will never become complete. |
Hey there! this code seem quite old, I'm not able to compile with that, so following the structure I was able to download an application from play store with this: public static final String KEY_AUTHORIZATION_TOKEN = "authToken";
public static final String KEY_ANDROID_ID_HEX = "androidIdHex";
public static final String KEY_FILTER_LEVEL = "filterLevel";
public static final String KEY_HTTP_USER_AGENT = "userAgent";
AndroidContext android = AndroidContext.baseDevice()
.setEmail(GOOGLE_EMAIL)
.setAndroidId(GOOGLE_GSF_ID)
.buildClientId("am-android")
.setCellOperator("31020", "T-Mobile");
String authToken = new AndroidAuth().getAuthTokenResponse(android, GOOGLE_PASS, "androidmarket",
"com.android.vending", "10321bd893f69af97f7573aafe9de1dc0901f3a1" /* Google's sig hash */,
false, AuthType.Password).getData(DataField.AUTH_TOKEN);
RequestContext req = new RequestContext();
req.set(KEY_ANDROID_ID_HEX, android.getAndroidIdHex());
req.set(KEY_AUTHORIZATION_TOKEN, authToken);
req.set(KEY_FILTER_LEVEL, 3);
req.set(KEY_HTTP_USER_AGENT,
"Android-Finsky/4.0.25 (api=3,versionCode=80200025,sdk=17,device=mako,hardware=mako,product=occam)");
DfeClient client = new DfeClient(req);
AppDetails appDetails = client.details(appPackage).getResponse().docV2.details.appDetails;
DfeResponse<DeliveryResponse> deliver = client.deliver(appPackage, appDetails.versionCode);
if (deliver.getResponse() == null || (deliver.getResponse().status != null
&& deliver.getResponse().status == 3)) {
client.purchase(appPackage, appDetails.versionCode);
deliver = client.deliver(appPackage, appDetails.versionCode);
}
AndroidAppDeliveryData appDeliveryData = deliver.getResponse().appDeliveryData;
downloadApk(appDeliveryData.downloadUrl, Environment.getExternalStorageDirectory()
+ "/"
+ appPackage
+ "-"
+ appDetails.versionCode
+ ".apk", appDeliveryData.downloadAuthCookie);
private static void downloadApk(String url, String fileName, List<HttpCookie> cookies)
throws IOException {
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
for (HttpCookie cookie : cookies) {
con.setRequestProperty("Cookie", cookie.name + "=" + cookie.value);
}
con.setDoInput(true);
if (con.getResponseCode() != 200) {
System.out.println("Error! " + con.getResponseMessage());
} else {
InputStream inputStream = con.getInputStream();
FileOutputStream fos = new FileOutputStream(fileName);
int n = con.getContentLength();
byte[] buffer;
while (n > 0) {
buffer = new byte[Math.min(n, 1024)];
int read = inputStream.read(buffer);
fos.write(buffer, 0, read);
n -= read;
}
inputStream.close();
fos.close();
}
} GOOGLE_EMAIL, GOOGLE_PASS and GOOGLE_GSF_ID are your own data 👍 Thanks for your hard work |
Hey Marvin, great code and thanks for your hard work! Just one small question, any idea inside Unsorted.proto, what are these "incremental" and "sideloadedAppCount" standing for? Many thanks! |
Could you add some hint/tips on how to use this project?
The text was updated successfully, but these errors were encountered: