【问题标题】:Query purchase products info returns Invalid Value use Google Play Developer API查询购买产品信息返回 Invalid Value 使用 Google Play Developer API
【发布时间】:2016-08-15 11:58:31
【问题描述】:

这个问题可能和here类似,但有些不同

1、我通过this得到client_id client_secret

2、我通过以下方式获取授权码: https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri={REDIRECT_URIS}&client_id={CLIENT_ID}

3、通过以下方式获取refresh_token:

urls := "https://www.googleapis.com/oauth2/v4/token"

postData := "redirect_uri=%s&grant_type=authorization_code&client_id=%s&client_secret=%s&code=%s"
postData = fmt.Sprintf(postData, url.QueryEscape(REDIRECT_URL), url.QueryEscape(CLIENT_ID), url.QueryEscape(CLIENT_SECRET), url.QueryEscape(CODE))
beego.Debug("postData:", postData)

body, err := service.Post(urls, "application/x-www-form-urlencoded", bytes.NewReader([]byte(postData)))

4、我通过以下方式获取access_token:

urls := "https://www.googleapis.com/oauth2/v4/token"

postData := "grant_type=refresh_token&client_id=%s&client_secret=%s&refresh_token=%s"
postData = fmt.Sprintf(postData, url.QueryEscape(CLIENT_ID), url.QueryEscape(CLIENT_SECRET), url.QueryEscape(REFRESH_TOKEN))
beego.Debug("postData:", postData)

body, err := service.Post(urls, "application/x-www-form-urlencoded", bytes.NewReader([]byte(postData)))

我想获取产品信息:

urls := "https://www.googleapis.com/androidpublisher/v2/applications/%s/purchases/products/%s/tokens/%s"
urls = fmt.Sprintf(urls, url.QueryEscape("cn.wps.moffice_premium"), url.QueryEscape("premium_sub_m"), url.QueryEscape("fngalnikxxxxxxcncnbfa.AO-J1OxEoo9RnI-tFqxxxxxxB6u-xbsnp74QYZQYsw_yDyLxxxxxxxaAohBFeafRTZBIioiljUt_ZVbexxxxxxPV7jD_QPQTpmftxpoQGzGloApv9mJnxBe5thDxxxxxxxLhpRRRWlK"))
header := http.Header{}
header.Add("Authorization", "Bearer "+accessToken)
body, err := service.Get(urls, header)

我错了:

 {
 "error": {
 "errors": [
  {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

我试试这个url可以返回有效值:

"https://www.googleapis.com/androidpublisher/v2/applications/%s/purchases/subscriptions/%s/tokens/%s"

不知道还有什么可以尝试的。 感谢您的帮助和回复

【问题讨论】:

    标签: google-play


    【解决方案1】:

    我找到了原因。我的订单商品类型是“subs”,所以不能使用这个Purchases.products 我使用订单项目类型“inapp”,使用 Purchases.products 返回 200。

    【讨论】:

      猜你喜欢
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-28
      • 1970-01-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多