Google Play开发者API-400无效值-InApp购买 [英] Google Play Developer API - 400 Invalid Value - InAppPurchases

查看:364
本文介绍了Google Play开发者API-400无效值-InApp购买的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题类似于这个问题.但是,我正在使用 API Java客户端库使用服务帐户,从我的服务器调用API.

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.

我的代码遵循指南,该指南非常简单.但是,我似乎无法为我的请求得到适当的错误.这就是我建立AndroidPublisher:

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()

从开发者控制台"的服务帐户"下生成JSON的位置.这是我发出请求的方式:

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()

我的订阅ID有效,但令牌无效.我预计响应中会出现诸如无效令牌"之类的错误.但是,我得到的是:

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?

更多信息:

  • 尝试从API资源管理器进行调用时也会遇到相同的错误(这次使用客户端ID和API密钥而不是服务帐户).
  • 我没有没有委派该服务帐户在域范围内的访问权限.我是否必须出于某些原因?
  • 我可以成功地对该API进行其他调用,例如 inappproducts.list
  • 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

推荐答案

所以,发生的原因仅仅是因为我使用的purchaseToken错误.

So, the reason that happened was just because the purchaseToken I was using was wrong.

我没有想到这就是原因,因为我认为在令牌无效的情况下,我会收到令牌无效"错误(或类似的错误).事实证明,Google给出的响应非常不一致(对于无效的令牌也可以给出404).

I did not expect that to be the reason as I thought that in the case of an invalid token, I would receive a "token invalid" error (or something similar). As it turns out, the responses given by Google are pretty inconsistent (a 404 could also be given for an invalid token).

这篇关于Google Play开发者API-400无效值-InApp购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆