Php 谷歌云存储桶->;第403页

Php 谷歌云存储桶->;第403页,php,google-cloud-platform,google-cloud-storage,Php,Google Cloud Platform,Google Cloud Storage,我试图检查Laravel PHP中是否存在一个bucket。 我在exists()方法上得到一个403。为什么? 见第160行 您的服务帐户没有存储.bucket.get权限。要检查bucket是否存在并创建它,请将角色/storage.admin分配给您的服务帐户 有关参考,请参阅: $storageClient = new \Google\Cloud\Storage\StorageClient([ 'projectId' => env('GCS_PROJECT_ID')

我试图检查Laravel PHP中是否存在一个bucket。 我在exists()方法上得到一个403。为什么?

见第160行


您的服务帐户没有
存储.bucket.get
权限。要检查bucket是否存在并创建它,请将
角色/storage.admin
分配给您的服务帐户

有关参考,请参阅:

$storageClient = new \Google\Cloud\Storage\StorageClient([
    'projectId' => env('GCS_PROJECT_ID'),
    'keyFilePath' => storage_path(env('GCS_KEY_FILE')),
]);
$bucket = $storageClient->bucket('mybucketname');

if (!$bucket->exists()) {
    $bucket = $storageClient->createBucket('mybucketname');
}

{ "error": {
    "code": 403,
    "message": "myaccount@api-project-xxxxxxxxx.iam.gserviceaccount.com does not have storage.buckets.get access to downloads.",
    "errors": [ {
        "message": "myaccount@api-project-xxxxxxxx.iam.gserviceaccount.com does not have storage.buckets.get access to mybucketname.",
        "domain": "global",
        "reason": "forbidden"
    } ]
} }