GoneToneStudio / node-google-play-api

Access Google Play by logging in and making requests as an Android device!
https://www.npmjs.com/package/@gonetone/google-play-api
MIT License
36 stars 9 forks source link

Error downloading apk #2

Closed limjianhui closed 3 years ago

limjianhui commented 3 years ago

Error: Download "com.github.android" Apk Failed: Get "com.github.android" Download Apk Url Failed: Get "com.github.android" Download Info Failed: Make "com.github.android" Purchase Request Failed: 從伺服器擷取資訊時發生錯誤。DF-DFERH-01

I followed the instructions in the readme.MD file. gpAPI.appDetails("com.github.android") works fine. Downloading does not. Any ideas why?

GoneTone commented 3 years ago

My test is work. Please send your code to me to check.

limjianhui commented 3 years ago
const GooglePlayAPI = require("@gonetone/google-play-api");

const gpAPI = new GooglePlayAPI("xxxxxxxxxxxxxxxx@gmail.com", "3D4Dxxxxxxxxxxxx");

gpAPI.setUserAgent("User-Agent");
gpAPI.setClientID("am-android-asus");
gpAPI.setSdkVersion(28);
gpAPI.setCountryCode("tw");
gpAPI.setLanguageCode("zh-TW");

const oauthToken =
    "oauth2_4/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

// Works
gpAPI.getGoogleToken(oauthToken, "save/token.txt").then(async (token: string) => {
    await gpAPI.googleAuth(token);

    const details = await gpAPI.appDetails("com.github.android");

    console.log(`Title: ${details.title}`);
    console.log(`Description Html: ${details.descriptionHtml}`);
    console.log(`Developer Name: ${details.details.appDetails.developerName}`);
    console.log(`Version Code: ${details.details.appDetails.versionCode}`);
    console.log(`Version String: ${details.details.appDetails.versionString}`);
    console.log(`Package Name: ${details.details.appDetails.packageName}`);
    console.log(`Share Url: ${details.shareUrl}`);

    console.log(details);
});

// Triggers error
gpAPI.getGoogleToken(oauthToken, "save/token.txt").then(async (token: string) => {
    try {
        await gpAPI.googleAuth(token);
        await gpAPI.downloadApk("com.github.android", "save_folder");
    } catch (error) {
        console.log(error);
    }
});
limjianhui commented 3 years ago

Ok this is weird

... and it works.

limjianhui commented 3 years ago

Ok, I've isolated the cause of the issue.

I have no idea what gpAPI.setUserAgent("User-Agent"); does, but adding it in my code causes an error. Other than that, code works fine!

GoneTone commented 3 years ago

setUserAgent parameter cannot be "User-Agent".

The following is an example:

Android-Finsky/20.4.13-all%20%5B0%5D%20%5BPR%5D%20313854362 (api=3,versionCode=82041300,sdk=28,device=ASUS_Z01QD_1,hardware=qcom,product=WW_Z01QD,platformVersionRelease=9,model=ASUS_Z01QD,buildId=PKQ1.190101.001,isWideScreen=0)

In addition, any settings are optional.