我意识到不久前还会出现类似的问题,但是我已经完成了解决这些问题的步骤。我正在尝试通过网络应用使用Google Play IAP验证端点(androidpublisher.inapppurchases.get)。我在关联的Google API控制台帐户中创建了一个服务帐户(请确保为“所有者”角色提供权限),并授予该用户“管理员”对Play商店帐户的访问权限,并且正在使用下载的密钥来获取访问令牌
请求:
GET https://www.googleapis.com/androidpublisher/v3/applications/#{package_name}/purchases/products/#{product_id}/tokens/#{token}
Authorization: Bearer #{access_token}
响应:
{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "permissionDenied",
"message": "The current user has insufficient permissions to perform the requested operation."
}
],
"code": 401,
"message": "The current user has insufficient permissions to perform the requested operation."
}
}
作为健全性检查,请求tokeninfo返回该服务帐户的预期用户ID:
GET https://www.googleapis.com/oauth2/v3/tokeninfo
Authorization: Bearer #{access_token}
响应:
{
"azp": "#{service_account_unique_id}",
"aud": "#{service_account_unique_id}",
"scope": "https://www.googleapis.com/auth/androidpublisher",
"exp": "1544468156",
"expires_in": "3600",
"access_type": "offline"
}