Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play Developer API - 400 Invalid Value - InAppPurchases

My question is similar to this one. However, I am using the API Java Client Library with a service account, making calls to the API from my server.

My code is following this guide, which is very simple. However, I can't seem to get an appropriate error for my request. This is how I build my AndroidPublisher:

val credential = GoogleCredential.fromStream(FileInputStream(
        "/path/to/json"
)).createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))

androidPublisher = AndroidPublisher.Builder(httpTransport, JSON_FACTORY, credential)
        .setApplicationName(packageName)
        .build()

Where the JSON is generated from the Developer Console, under Service Accounts. This is how I make my request:

androidPublisher.purchases().subscriptions().get(packageName, "valid-sku", "invalid-token").execute()

My subscription ID is valid but my token is invalid. I expect an error such as "invalid token" in the response. However, what I get is:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid Value",
    "reason" : "invalid"
  } ],
  "message" : "Invalid Value"
}

Is that a generic error because of the invalid token or is it an authentication issue? If it an authentication issue, how do I solve it? If it is an invalid token issue, how am I supposed to know?

Some more information:

  • I get the same error when trying to make that call from the API Explorer as well (this time using a Client ID and API Key instead of Service Account).
  • I have not delegated domain-wide access to the service account. Do I have to for some reason?
  • I can successfully make other calls to the API such as inappproducts.list
like image 419
pavlos163 Avatar asked Sep 05 '17 12:09

pavlos163


2 Answers

From my experiences, if you have HTTP 400 error with Invalid Value then that purchase or subscription is FRAUD.

You can check out Order Id part of those purchases. Probably in the format of XXXXXXXXXXXX.XXXXXXXXXXXX which is wrong and should be GPA.XXXX.XXXXX.XXXXX.XXX

  • I don't really count the X char number. I just added to show the logic.
like image 164
Berkay Turancı Avatar answered Nov 07 '22 00:11

Berkay Turancı


In my case the problem was that I was calling:

purchases.products.get

Instead of:

purchases.subscriptions.get
like image 42
Mr Stanev Avatar answered Nov 07 '22 01:11

Mr Stanev