Google Play 开发者 API 未返回刷新令牌



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

根据文档,它应该返回我以下响应:

{
  "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>

请帮助我缺少什么。

好的。我发现了实际问题。这确实缺乏 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,可以按照此答案中提到的步骤进行操作,然后尝试再次获取refresh_token

最新更新