【问题标题】:service account (403) Forbidden Google Play In-app Billing Purchase Status API服务帐户 (403) 禁止 Google Play 应用内结算购买状态 API
【发布时间】:2014-03-18 05:55:47
【问题描述】:
<?php
include_once('./src/Google_Client.php');
include_once('./src/contrib/Google_AndroidpublisherService.php');

//user token, in json format
$ANDROIDUsertoken = '{"orderId":"12999763169054705758.1323390433376399","packageName":"org.luan.hellocpp","productId":"1","purchaseTime":1394183520430,"purchaseState":0,"purchaseToken":"rurmodmieoumgowoquecqhnv.AO-J1Ow43-aM8CXNWlUcUYmA06bIaYzZPcCJCua0lLxnihOULX27Jg6NvqNUlWMpoENxtdHCIVSm6AM2mVkiC0ABSch2JEKmu1zqsVM46L762H5ppF4AIcE"}';
$user_token= json_decode($ANDROIDUsertoken,true);

// https://developers.google.com/console/help/#service_accounts
const CLIENT_ID = '1048550291137-rfqol5nm4k9tqr0a5bupedoakhd184k4.apps.googleusercontent.com';
const SERVICE_ACCOUNT_NAME = '1048550291137-rfqol5nm4k9tqr0a5bupedoakhd184k4@developer.gserviceaccount.com';
const KEY_FILE = './key.p12';

$client = new Google_Client();
$client->setApplicationName($user_token['packageName']);
$client->setClientId(CLIENT_ID);

$key = file_get_contents(KEY_FILE);

$auth = new Google_AssertionCredentials(
    SERVICE_ACCOUNT_NAME,
    array('https://www.googleapis.com/auth/androidpublisher'),
    $key);

$client->setAssertionCredentials($auth);

//$client->getAuth()->refreshTokenWithAssertion();
//$accessToken=$client->getAccessToken();
//$client->setAccessToken($accessToken);

$AndroidPublisherService = new Google_AndroidPublisherService($client);
$res = $AndroidPublisherService->inapppurchases->get($user_token['packageName'], $user_token['productId'], $user_token['purchaseToken']);

var_dump($res);
?>

错误返回:

PHP Fatal error:  Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/androidpublisher/v1.1/applications/org.luan.hellocpp/inapp/1/purchases/rurmodmieoumgowoquecqhnv.AO-J1Ow43-aM8CXNWlUcUYmA06bIaYzZPcCJCua0lLxnihOULX27Jg6NvqNUlWMpoENxtdHCIVSm6AM2mVkiC0ABSch2JEKmu1zqsVM46L762H5ppF4AIcE: (403) Forbidden' in /var/www/debug/google/src/io/Google_REST.php:66
Stack trace:
#0 /var/www/debug/google/src/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 /var/www/debug/google/src/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest))
#2 /var/www/debug/google/src/contrib/Google_AndroidpublisherService.php(39): Google_ServiceResource->__call('get', Array)
#3 /var/www/debug/google/purchase.php(32): Google_InapppurchasesServiceResource->get('org.luan.helloc...', '1', 'rurmodmieoumgow...')
#4 {main}
  thrown in /var/www/debug/google/src/io/Google_REST.php on line 66

当我使用服务帐户查询购买状态 api 时,我收到了 Forbidden 错误 403。 Google Developers Console 中的 Google Play Android Developer API 状态已设置为 on。 谁能帮我。谢谢

【问题讨论】:

    标签: google-api in-app-purchase in-app-billing


    【解决方案1】:

    我刚刚解决了这个问题。

    您必须在您的 google play 发布页面(https://play.google.com/apps/publish/,而不是 google 开发者控制台)中添加服务帐户电子邮件(“1048550291137-rfqol5nm4k9tqr0a5bupedoakhd184k4@developer.gserviceaccount.com”)。

    在“设置”-“用户账号和权限”,“邀请新用户”,用服务账号邮箱提交,勾选“查看财务报告”右侧,一切正常~

    【讨论】:

    • 我正在尝试验证购买,但是在开发者项目与应用程序链接后,用户被邀请,验证管理员权限(所有检查,包括财务报告),身份验证,获取令牌和执行请求,它一直响应“当前用户没有足够的权限执行请求的操作。”。有任何想法吗??我不知道这个主题有什么。
    猜你喜欢
    • 2014-06-21
    • 2014-03-25
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 2016-06-11
    相关资源
    最近更新 更多