我正在尝试在我的应用程序中使用来自 Google Play 的新 Android 订阅系统(我的应用内计费已经正常工作)。我已成功完成订阅计费,但我现在想使用 android 文档 (http://developer.android.com/guide/market/billing/billing_subscriptions.html) 中所示的 google api 检索有关此订阅的信息.
我希望我的服务能够执行 API 调用来检索这些信息,但是我在身份验证方面遇到了问题(使用 oauth2)。到目前为止,这就是我所做的(在我的 php 服务中):
require_once 'google-api-php-client/src/apiClient.php'
const SERVICE_ACCOUNT_NAME = 'email from services account access';
$key = 'content of my private key retrieved from services account access';
$client = new apiClient();
$cred = new apiAssertionCredentials(SERVICE_ACCOUNT_NAME, array('https://www.googleapis.com/auth/androidpublisher'), $key);
$assertion = $cred->generateAssertion(); // This generate my encrypted JWT
然后我尝试使用此 JWT 对象检索访问令牌。问题是,当我使用给定的访问令牌时,我收到开发人员帐户不拥有应用程序的错误,这是不正确的。
(我知道这不是这样做的方法,但我只是想使用 JWT 检索 access_token 以了解它为什么不起作用,如果我按照 google apis 文档中的指示进行操作,它也不起作用)。
我需要从服务器进行此 API 调用,因此无需涉及最终用户(无需手动同意)。