【发布时间】:2014-09-21 19:04:06
【问题描述】:
我正在尝试使用 PHP 库访问 bigquery api,但我总是遇到此错误:
致命错误:未捕获的异常“Google_Service_Exception”带有消息“调用 GET https://www.googleapis.com/bigquery/v2/projects/primeval-shadow-571/datasets/Test/tables 时出错:(401) 需要登录”...
我有一个 Web 应用程序,它需要从 bigquery 中的表中获取一些数据。远程帐户不是我的,但它是由某个人创建的(而且我没有登录和密码登录),他给了我包含这些参数的 .json 文件:
auth_uri,
client_secret,
token_uri,
client_email,
client_x509_cert_url,
client_id and
auth_provider_x509_cert_url.
这是我的 php 代码:
<?php
require_once 'Google/Client.php';
require_once 'Google/Service/Bigquery.php';
$client = new Google_Client();
$client->setAuthConfigFile('google-config.json');
$service = new Google_Service_Bigquery($client);
$service->tables->listTables('primeval-shadow-571', 'Test');
但最后我得到了上面的错误。
谁能告诉我哪里错了?
附:两天前我刚开始使用google api,所以我才刚刚开始学习它。
非常感谢。
【问题讨论】:
标签: php oauth-2.0 google-bigquery google-api-php-client