我在调用 Google Play Developer API 时遇到问题。
我已按照 https://developers.google.com/android-publisher/authorization 上列出的所有步骤进行操作。这包括
然后,为了调用 purchases.subscriptions.get API,我使用了以下 CURL 命令:
(https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get)
curl -X GET "https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}" -H "Authorization: Bearer {access_token}" -H "Accept: application/json" --compressed
但是,我收到以下错误:
"error": {
"code": 401,
"message": "The current user has insufficient permissions to perform the requested operation.",
"errors": [
{
"domain": "androidpublisher",
"message": "The current user has insufficient permissions to perform the requested operation.",
"reason": "permissionDenied"
}
]
}
}
我已经阅读并实施了其他帖子中推荐的更改,例如
我也试过通过 https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get#authorization-scopes 但仍然没有运气(出错)。
如果有人有任何建议,那将不胜感激。谢谢。
我遇到了类似的问题,问题出在我们在谷歌开发者项目中所做的设置中。
参考create-play-service-credentials设置。使用与您创建应用内商品相同的主帐户。
确保删除前一个。
链接到谷歌开发者项目 您的 Play 开发者帐户需要链接到 Google 开发者项目。
1a。打开设置 > 开发者帐户菜单并选择 API 访问
1b。选择链接将您的 Play 帐户连接到 Google 开发者项目
1c。同意条款和条件
2。创建服务帐户 接下来我们需要创建一个服务帐户。这是从 Google API 控制台完成的。
2a。选择创建服务帐户
2b。创建服务帐户密钥凭据
2c。输入服务帐户的详细信息
3。授予访问权限
3a。在 Play Console 中,选择对新创建的服务帐户授予访问权限
3b。授予以下权限:
3c.点击底部的邀请用户并发送邀请
您将被重定向到用户和权限,您应该在其中看到新创建的服务帐户处于活动状态。
我遇到了同样的问题。就我而言,在后端验证购买时,我没有为 Google Play 上授予的服务帐户使用密钥文件(json one)。我用 Google Play 上授予的服务帐户之一替换了错误的密钥文件,现在它工作正常。