项目所有者的权限不足,无法验证应用订阅中的 google

Not enough permission from project owner to verify google in app subscriptions

我正在尝试在我的服务器端验证 google 应用程序订阅。

在我看来,我需要为此创建一个服务帐户。

链接google后播放到google云平台。我看到它在我的 google 云平台上自动创建了一个项目 "Google Play Android Developer"。

现在,我在项目 "Google Play Android Developer" 下创建了一个服务帐户,并在整个项目上创建了 "owner role"。

但出于某种原因,当我使用此服务帐户并尝试验证 purchaseToken 时,出现错误 "The current user has insufficient permissions to perform the requested operation"。

我正在使用这个 https://www.npmjs.com/package/iap 库的 nodejs 后端。

iap.verifyPayment('google', {
  receipt: "<purchaseToken>",
  keyObject: {
    "type": "service_account",
    "project_id": "<project_id_that_was_created_for_me>",
    "private_key_id": "<private_key_id>",
    "private_key": "-----BEGIN PRIVATE KEY-----\nblah\n-----END PRIVATE KEY-----\n",
    "client_email": "google-play-owner@project_id_that_was_created_for_me.iam.gserviceaccount.com",
    "client_id": "---",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "---"
  },
  productId: "my.app.membership_1_month",
  subscription: true,
  packageName: "my.app"
}, function (error, response) {
  console.log(error);
});

这是我收到的错误

"errors": [
   {
    "domain": "androidpublisher",
    "reason": "permissionDenied",
    "message": "The current user has insufficient permissions to perform the requested operation."
   }
  ]

事实证明,我还需要在 google 游戏机 UI 上授予访问权限。

  1. https://play.google.com/apps/publish
    • 请勿点击进入您的任何应用程序
  2. 转到左侧的设置
  3. API 访问左侧
  4. 右侧的服务帐户
  5. 在那里授予权限或创建帐户