“当前用户没有足够的权限执行请求的操作。” - Google Play 开发者 API

问题描述 投票:0回答:3

我在调用 Google Play Developer API 时遇到问题。

我已按照 https://developers.google.com/android-publisher/authorization 上列出的所有步骤进行操作。这包括

  1. 创建项目并启用Google Play Android Developer API(使用我的 Google Play 控制台帐户)
  2. 通过 Settings > Developer Account > API Access 链接项目
  3. 通过 Google Play 控制台授予对应用程序具有财务权限的服务帐户的访问权限。
  4. Create OAuth 2.0 Client Id, Client Secret, and Redirect URI credentials.
  5. 通过发送 POST 请求生成刷新令牌访问令牌

然后,为了调用 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"
      }
    ]
  }
}

我已经阅读并实施了其他帖子中推荐的更改,例如

  1. 在授予权限或链接到服务帐户之前添加应用内产品/订阅
  2. 打开“应用内产品/订阅”并执行一些更新
  3. 通过 Google Play 控制台验证所有用户和权限
    • 例如。服务帐户是管理员用户
  4. 等待超过 48 小时,让 Google 传播 API 的所有访问权限。

我也试过通过 https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get#authorization-scopes 但仍然没有运气(出错)。

如果有人有任何建议,那将不胜感激。谢谢。

android google-api google-oauth google-api-client
3个回答
9
投票

我遇到了类似的问题,问题出在我们在谷歌开发者项目中所做的设置中。

参考create-play-service-credentials设置。使用与您创建应用内商品相同的主帐户。

确保删除前一个。

链接到谷歌开发者项目 您的 Play 开发者帐户需要链接到 Google 开发者项目。

1a。打开设置 > 开发者帐户菜单并选择 API 访问

1b。选择链接将您的 Play 帐户连接到 Google 开发者项目

1c。同意条款和条件

2。创建服务帐户 接下来我们需要创建一个服务帐户。这是从 Google API 控制台完成的。

2a。选择创建服务帐户

2b。创建服务帐户密钥凭据

2c。输入服务帐户的详细信息

2d。下载您的 JSON 凭证:

3。授予访问权限

3a。在 Play Console 中,选择对新创建的服务帐户授予访问权限

3b。授予以下权限:

3c.点击底部的邀请用户并发送邀请

您将被重定向到用户和权限,您应该在其中看到新创建的服务帐户处于活动状态。


0
投票

我遇到了同样的问题。就我而言,在后端验证购买时,我没有为 Google Play 上授予的服务帐户使用密钥文件(json one)。我用 Google Play 上授予的服务帐户之一替换了错误的密钥文件,现在它工作正常。


0
投票

30小时后,我发现我的问题,我在添加服务帐户后没有点击用户和权限页面上的添加应用程序按钮。

© www.soinside.com 2019 - 2024. All rights reserved.