【发布时间】:2018-10-20 14:32:01
【问题描述】:
我的目标是验证用户在谷歌服务器上的购买,如此处所述>Purchases.products: get
但我需要授权请求>Authorisation Documentation
根据Google Play Developer API Authorization Doccumentation以生成访问和刷新令牌:
"... 向 https://accounts.google.com/o/oauth2/token 发送 POST 请求,并设置以下字段:
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>
成功的响应将包含 JSON 格式的令牌:
{
"access_token" : "ya29.ZStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/zaaHNytlC3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
}
"
我从 console.developers.google.com 成功生成了代码、client_id、client_secret、redirect_uri 但是当我发送 POST 请求时
当我使用Postman 时得到以下响应:
{
"error": "invalid_request",
"error_description": "Missing header: Content-Type"
}
状态码 = 400
我在使用 Chrome 时得到以下响应:
{
"error": "invalid_request"
}
我怎样才能得到正确的回应?
【问题讨论】:
-
如何发送 POST 请求?您是通过浏览器、邮递员、Java 代码还是其他方式进行操作?如果您使用 java 发送它,请提供您的源代码。
-
我是通过邮递员和浏览器完成的
标签: android google-play in-app-billing google-developers-console play-billing-library