Credencial PHP da API do Google BigQuery
Quero implementar a API do Google BigQuery para que eu possa executar a consulta do meu código PHP no BigQuery.
Primeiro eu instalei a biblioteca do cliente seguindo o seguinte comando:
composer require google/cloud
Segundo, instalei o Google Cloud SDK seguindo o seguinte comando:
curl https://sdk.cloud.google.com | bash
Então, eu executo este comando para criar a credencial:
gcloud beta auth application-default login
Todo o processo é bem-sucedido e, depois de executar a solicitação de credencial, recebo a seguinte mensagem:
Credentials saved to file:
[/home/some/my/dir/application_default_credentials.json]
These credentials will be used by any library that requests
Application Default Credentials.
Então eu quero executar este código no PHP:
# 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 = 'PROJECT ID';
# Instantiates a client
$bigquery = new BigQueryClient([
'projectId' => $projectId
]);
# The name for the new dataset
$datasetName = 'my_new_dataset';
# Creates the new dataset
$dataset = $bigquery->createDataset($datasetName);
echo 'Dataset ' . $dataset->id() . ' created.';
Mas, infelizmente, recebi o seguinte erro de mensagem:
Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message 'Could not load the default credentials
Então, minha pergunta é: o que há de errado e o que devo fazer?
Obrigado