当前用户没有足够的权限google api

Tes*_*jay 4 android google-play google-play-services google-play-developer-api

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

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

我已经有一个“OldProject”链接到我的Google Play帐户,所以现在,我在项目“OldProject”下创建了一个服务帐户,在整个项目上具有“所有者角色”。

但由于某种原因,当我使用此服务帐户并尝试验证purchaseToken时,我收到错误“当前用户没有足够的权限来执行请求的操作”。

我正在使用这里的 PHP 验证器https://github.com/aporat/store-receipt-validator

但我不断收到此错误

    got error = { "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." } }
Run Code Online (Sandbox Code Playgroud)

是的,在 API 访问中,我已授予该用户作为所有应用程序的“管理员”权限

这是 PHP 代码

<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

$root = realpath(dirname(dirname(__FILE__)));
$library = "$root/library";

$path = array($library, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $path));

require_once $root . '/vendor/autoload.php';

use ReceiptValidator\GooglePlay\Validator as PlayValidator;

// google authencation 
$applicationName = 'xxx-xxx';
$scope = ['https://www.googleapis.com/auth/androidpublisher'];
$configLocation = 'googleapi.json';

// receipt data
$packageName = 'com.xxxx.xxxx';
$productId = 'xxx';
$purchaseToken = 'xxxx';

$googleClient = new \Google_Client();
$googleClient->setScopes([\Google_Service_AndroidPublisher::ANDROIDPUBLISHER]);
$googleClient->setApplicationName($applicationName);
$googleClient->setAuthConfig($configLocation);

$googleAndroidPublisher = new \Google_Service_AndroidPublisher($googleClient);
$validator = new \ReceiptValidator\GooglePlay\Validator($googleAndroidPublisher);

try {
  $response = $validator->setPackageName($packageName)
      ->setProductId($productId)
      ->setPurchaseToken($purchaseToken)
      ->validateSubscription();
} catch (\Exception $e){
  var_dump($e->getMessage());
  // example message: Error calling GET ....: (404) Product not found for this application.
}
// success
Run Code Online (Sandbox Code Playgroud)

Tes*_*jay 5

所以不得不等待超过 24 小时(在我的例子中是 37 小时),它开始工作......感谢谷歌浪费了我的时间并且没有写下我们必须等待更新