【发布时间】:2019-03-03 10:34:34
【问题描述】:
我正在尝试根据 https://github.com/GoogleCloudPlatform/php-docs-samples/blob/master/auth/src/auth_cloud_explicit.php 在代码中进行身份验证,但我不知道将什么作为 $serviceAccountPath 传递。我将私有 .json 文件复制到我的应用程序文件夹的根目录中。我需要在这里使用什么?
function auth_cloud_explicit($projectId, $serviceAccountPath)
{
# Explicitly use service account credentials by specifying the private key
# file.
$config = [
'keyFilePath' => $serviceAccountPath,
'projectId' => $projectId,
];
$storage = new StorageClient($config);
# Make an authenticated API request (listing storage buckets)
foreach ($storage->buckets() as $bucket) {
printf('Bucket: %s' . PHP_EOL, $bucket->name());
}
}
【问题讨论】:
标签: php google-cloud-platform google-cloud-storage google-cloud-functions