我正在尝试在服务器端验证Google在应用中的订阅。
在我看来,我需要为此创建一个服务帐户。
我已经有一个“ OldProject”链接到我的Google Play帐户,因此,现在,我在整个项目中的“所有者”角色下的“ OldProject”项目下创建了一个服务帐户。
但是由于某些原因,当我使用此服务帐户并尝试验证PurchaseToken时,出现错误“当前用户没有足够的权限来执行请求的操作”。
我正在https://github.com/aporat/store-receipt-validator此处使用PHP验证程序
但我一直收到此错误
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." } }
在“ 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
答案 0 :(得分:0)
因此必须等待24个小时以上(以我为例),并且开始工作了……感谢google浪费我的时间,而不是写信我们必须等待此更新