Google BigQuery API PHP Credential
Ich möchte die Google BigQuery-API implementieren, damit ich in BigQuery Abfragen aus meinem PHP-Code ausführen kann.
Zunächst habe ich die Client-Bibliothek mit folgendem Befehl installiert:
composer require google/cloud
Zweitens habe ich das Google Cloud SDK mit folgendem Befehl installiert:
curl https://sdk.cloud.google.com | bash
Dann führe ich diesen Befehl aus, um den Berechtigungsnachweis zu erstellen:
gcloud beta auth application-default login
All der Prozess ist erfolgreich und nach der Anforderung von Anmeldeinformationen erhalte ich die folgende Meldung:
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.
Dann möchte ich diesen Code auf PHP ausführen:
# 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.';
Aber leider habe ich folgende Fehlermeldung erhalten:
Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message 'Could not load the default credentials
Also meine Frage ist: Was ist falsch und was muss ich tun?
Vielen Dan