2
votes

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." 
    } 
}

I get this error when I try and create a bucket with a domain using the API. I can, however, create that same bucket in the dashboard visual interface in the console.

Does anyone know why this might happen? The Webmaster verification tools, the domain is listed as verified.

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

1 Answers

1
votes

I had to go to the following URL and add my service account.

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