title: Google Play Developer API - 400 Invalid Value - InAppPurchases
body: <p>My question is similar to <a href="https://stackoverflow.com/questions/35019357/google-play-developer-api-query-purchase-token-returns-invalid-value">this one</a>. However, I am using the <a href="https://developers.google.com/api-client-library/java/apis/androidpublisher/v2" rel="noreferrer">API Java Client Library</a> with a service account, making calls to the API from my server.</p>
  
  <p>My code is following <a href="https://developers.google.com/identity/protocols/OAuth2ServiceAccount" rel="noreferrer">this</a> guide, which is very simple. However, I can't seem to get an appropriate error for my request. This is how I build my <code>AndroidPublisher</code>:</p>
  
  <pre><code>val credential = GoogleCredential.fromStream(FileInputStream(
          "/path/to/json"
  )).createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
  
  androidPublisher = AndroidPublisher.Builder(httpTransport, JSON_FACTORY, credential)
          .setApplicationName(packageName)
          .build()
  </code></pre>
  
  <p>Where the JSON is generated from the Developer Console, under Service Accounts. This is how I make my request:</p>
  
  <pre><code>androidPublisher.purchases().subscriptions().get(packageName, "valid-sku", "invalid-token").execute()
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
  {
    "code" : 400,
    "errors" : [ {
      "domain" : "global",
      "message" : "Invalid Value",
      "reason" : "invalid"
    } ],
    "message" : "Invalid Value"
  }
  </code></pre>
  
  <p>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?</p>
  
  <p><strong>Some more information:</strong> </p>
  
  <ul>
  <li>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).</li>
  <li>I have <strong>not</strong> delegated domain-wide access to the service account. Do I have to for some reason?</li>
  <li>I can successfully make <strong>other calls</strong> to the API such as <a href="https://developers.google.com/android-publisher/api-ref/inappproducts/list" rel="noreferrer"><code>inappproducts.list</code></a></li>
  </ul>