我正在尝试使用 API 验证 Google Play 收据。我已经创建了服务帐户,启用了API,成功获取了令牌,但是当我向API发送请求进行验证时,出现未知错误,并且无法找到原因。
我的要求:
package_name = '...'
product_id = '...'
purchase_token = '...'
url = f"https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{package_name}/purchases/products/{product_id}/tokens/{purchase_token}"
response = requests.get(url, headers={'Authorization': f'Bearer {credentials.token}', 'Accept': 'application/json'})
错误:
{
"error": {
"code": 404,
"message": "The document type is not supported.",
"errors": [
{
"message": "The document type is not supported.",
"domain": "androidpublisher",
"reason": "unsupportedDocType",
"location": "token",
"locationType": "parameter"
}
]
}
我也遇到这个问题;问题是使用了错误的接口。 尝试:https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}
方法:购买.产品.get 方法:purchasing.subscriptions.get
解决思路来自于下面的问题。 Android:应用内购买收据验证 google play