【问题标题】:Google Play developer API not returning refresh tokenGoogle Play 开发者 API 未返回刷新令牌
【发布时间】:2019-04-07 13:37:14
【问题描述】:

我想使用Purchase.Subscription API 获取订阅数据。为此,我试图从https://accounts.google.com/o/oauth2/token 获取令牌。

根据documentation,它应该返回以下回复:

{
  "access_token" : "ya29.ZStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
  "token_type" : "Bearer",
  "expires_in" : 3600,
  "refresh_token" : "1/zaaHNytlC3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
}

但是当我尝试执行相同的步骤时,我没有得到 refresh_token 字段作为响应。 我正在发送文档中提到的以下字段:

grant_type=authorization_code
code=<the code from the previous step>
client_id=<the client ID token created in the APIs Console>
client_secret=<the client secret corresponding to the client ID>
redirect_uri=<the URI registered with the client ID>

请帮我解决我所缺少的。

【问题讨论】:

  • 请在此处发布您的一些代码
  • 你会得到什么回报?
  • 我已经在上面提到了响应与文档中描述的相同,除了 refresh_token 即将到来

标签: android google-play google-play-developer-api


【解决方案1】:

好的。我发现了实际问题。这在 API 方面确实缺乏文档。在允许应用管理您的开发者帐户后,我们将仅在第一次使用以下数据调用 api https://accounts.google.com/o/oauth2/token 时获得 refresh_token 值:

grant_type=authorization_code
code=<the code from the previous step>
client_id=<the client ID token created in the APIs Console>
client_secret=<the client secret corresponding to the client ID>
redirect_uri=<the URI registered with the client ID>

如果您没有获得 refresh_token,您可以按照answer 中提到的步骤尝试再次获取 refresh_token

【讨论】:

    猜你喜欢
    • 2012-12-27
    • 2012-04-10
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 2013-06-17
    • 1970-01-01
    相关资源
    最近更新 更多