我正在尝试使用 Firebase 设置 Google Bigquery,但遇到了一些问题。我已经gcloud
安装在我的机器(MacOS Sierra)上,并在我的项目中通过 composer 安装了谷歌云。
我的项目中的以下代码:
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use Google\Cloud\BigQuery\BigQueryClient;
# Your Google Cloud Platform project ID
$projectId = 'hidden here only';
# Instantiates a client
$bigquery = new BigQueryClient([
'projectId' => $projectId
]);
# The name for the new dataset
$datasetName = 'test_dataset';
# Creates the new dataset
$dataset = $bigquery->createDataset($datasetName);
echo 'Dataset ' . $dataset->id() . ' created.';
我要做的只是通过库在 bigquery 中创建一个数据集,但由于以下错误,我无法做到:
Fatal error: Uncaught Google\Cloud\Exception\ServiceException: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information in /Applications/MAMP/htdocs/projects/work/bigquery-tests/vendor/google/cloud/src/RequestWrapper.php on line 219
我已经尝试gcloud beta auth applications-default login
按照示例代码所说的那样运行,但是在登录浏览器后,错误仍然存在。任何帮助都会很棒,谢谢!