【发布时间】:2021-08-20 21:18:29
【问题描述】:
我一直按照here 和here 的步骤尝试使用服务帐户密钥文件来访问 Google pay api 并插入 LoyaltyClass。 Google Pay 库建议使用 1.1.1 版的 Google api 客户端库,这就是我在这里所做的:
$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/wallet_object.issuer');
$client->setApplicationName("Test");
$client->setDeveloperKey("My service account key");
$test_class = new LoyaltyClass;
$service = new Google_Service_Walletobjects($client);
$wallet_object = $test_class->create_wallet_class();
$service->loyaltyclass->insert($wallet_object);
我得到这个错误:
PHP Fatal error: Uncaught Google_Service_Exception: Error calling POST https://www.googleapis.com/walletobjects/v1/loyaltyClass?key=2ee78c76d17cabcdce22c4e89af27ab73ad694a4: (401) Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project. in /var/www/html/google-api-php-client/src/Google/Http/REST.php:76
云 api 控制台记录了我使用正确的服务帐户访问了 api,但没有记录任何请求。他们建议的链接指示我提示用户登录,但我想在没有用户输入的情况下访问这个 api,只是我的服务帐户。有没有办法做到这一点?
【问题讨论】:
标签: php google-pay