未配置Google云端存储服务帐户访问权限

时间:2013-02-21 10:07:41

标签: php google-cloud-storage

我正在开发一个PHP脚本,可以自动将PDF文档上传到Google云端 桶。

我正在使用Google的云存储服务帐户。

我得到的结果是: 调用GET https://www.googleapis.com/storage/v1beta1/b/时出错..:(403)Access Not Configured

我正在使用的PHP代码(php google api client lib)如下:

$clientID = 'MY CLIENT ID';
$keyFile = 'PATH\TO\KEYFILE\key.p12';
$key_secret = 'MY KEY SECRET';

$client = new Google_Client();
$client->setClientId($clientID);
$client->setApplicationName("Google Cloud Storage Sample");
$client->setScopes('https://www.googleapis.com/auth/devstorage.full_control');

$key = file_get_contents($keyFile);
$client->setAssertionCredentials(new Google_AssertionCredentials(
    'service account name',
    array('https://www.googleapis.com/auth/devstorage.full_control'),
    $key,$key_secret)
);

$storageService = new Google_StorageService($client);
try 
{
   $bucket = $storageService->buckets->get('my_bucket');


}      
catch (exception $e)
{
    print $e->getMessage();
}


Thanks for any support on this one.

0 个答案:

没有答案