无法使用API​​创建存储桶,但允许在控制台中使用

时间:2017-02-10 20:07:50

标签: php google-app-engine google-cloud-storage

ERROR

Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message 

{ 
    "error": { 
        "errors": [ 
            { 
                "domain": "global",
                 "reason": "forbidden", 
                 "message": "The bucket you tried to create is a domain name owned by another user." 
            } 
        ], 
        "code": 403, 
        "message": "The bucket you tried to create is a domain name owned by another user." 
    } 
}

当我尝试使用API​​创建一个包含域的存储桶时,我收到此错误。但是,可以,在控制台的仪表板可视界面中创建相同的存储桶。

有谁知道为什么会这样?网站管理员验证工具,该域名已经过验证。

putenv('GOOGLE_APPLICATION_CREDENTIALS=../../service-account.json');

# Your Google Cloud Platform project ID
$projectId = 'PROJECT';

# Instantiates a client
$storage = new StorageClient([
    'projectId' => $projectId
]);

# The name for the new bucket
$bucketName = 'somethingsomething123.domain.co';

# Creates the new bucket
$bucket = $storage->createBucket($bucketName); 

echo 'Bucket ' . $bucket->name() . ' created.';

1 个答案:

答案 0 :(得分:1)

我必须转到以下网址并添加我的服务帐户。

https://www.google.com/webmasters/verification/details?hl=en&domain=[YOUR-DOMAIN.COM]