Closed limjianhui closed 3 years ago
My test is work. Please send your code to me to check.
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);
}
});
Ok this is weird
... and it works.
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!
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.
I followed the instructions in the
readme.MD
file.gpAPI.appDetails("com.github.android")
works fine. Downloading does not. Any ideas why?