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

VersionCode and VersionString is null for "com.spotify.tv.android", thus application crushing at downloading. #3

Closed its-mash closed 3 years ago

its-mash commented 3 years ago

Crashing at Purchase function:

  async purchase (packageName, offerType, versionCode) {
    try {
      const axiosData = await axios.post(`${this._apiEndpoint}${this._playApiPath}/purchase`, qs.stringify({
        doc: packageName.toString(),
        ot: offerType.toString(),
        vc: versionCode.toString() //--------------->versionCode is null<------------------
      }), this._axiosConfigForGooglePlay)

      // noinspection JSUnresolvedVariable
      return this._protoBuf.decode(axiosData.data).payload.buyResponse
    } catch (e) {
      throw Error(`Make "${packageName}" Purchase Request Failed: ${(typeof e.response !== 'undefined') ? this._protoBuf.decode(e.response.data).commands.displayErrorMessage : e.message}`)
    }
  }

Note: I didn't call gpAPI.setSdkVersion() & gpAPI.setUserAgent()

GoneTone commented 3 years ago

Device does not support.

Try to set gpAPI.setUserAgent(), gpAPI.setClientID() as a supported device.

Actually I’m not sure, I don’t have an Android TV...

GoneTone commented 3 years ago

I found a way, you need to get the GSF ID of your Android TV.

You can download it on other devices https://play.google.com/store/apps/details?id=com.evozi.deviceid, then backup as APK, transfer it to your Android TV and install it.

Example code:

const GooglePlayAPI = require('@gonetone/google-play-api')

const gpAPI = new GooglePlayAPI("Your_Google_Account@gmail.com", "The GSF ID of your Android TV")

gpAPI.getGoogleToken('Your OAuth2 Token', 'save/token.txt').then(async (token) => {
  await gpAPI.googleAuth(token)

  const details = await gpAPI.appDetails('com.spotify.tv.android')

  console.log(`Version Code: ${details.details.appDetails.versionCode}`)
  console.log(`Version String: ${details.details.appDetails.versionString}`)
})

Result:

image