我正嘗試從Google Play使用新的Android訂閱系統進入我的應用程序(我已經有了應用內結算工作正常)。我已經成功完成了訂閱計費,但是現在我想通過使用google apis檢索有關此訂閱的信息,如android文檔(http://developer.android.com/guide/market/billing/billing_subscriptions.html)中所示。 。Android訂閱和谷歌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調用,因此不需要最終用戶參與(無需手動同意)。
@艾哈邁德...這看起來像是從「全能!」的答案。 – dell116
以下是如何手動執行此操作:https://developers.google.com/android-publisher/authorization – Chloe