google play 支付验证--踩坑

正常的流程: 参考 https://github.com/googleapis/google-api-php-client

//安卓支付成功后传过来的
$product_id = '0001';
$purchase_token = 'xxxxxxx';
$package_name = 'com.xxxxx';

//注册好service account后下载秘钥json文件
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/xxxx.json');
$google_client = new \Google_Client();
$google_client->useApplicationDefaultCredentials();
$google_client->addScope(\Google_Service_AndroidPublisher::ANDROIDPUBLISHER);
$androidPublishService = new \Google_Service_AndroidPublisher($google_client);
$result = $androidPublishService->purchases_products->get(
	$package_name,
	$product_id,
	$purchase_token
);

看上去一切都很完美,然鹅,问题来了。。。

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

死活都是401。。。没道理啊,我新建的service account是project owner啊,为什么呢。。。

原来要把新建的service account的那个email加到测试组里

然后,你懂的。。。。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值