I am currently moving from Amazon S3 to Google Storage, and I cannot get my credentials to work. Here is an example of the code that I put together to verify my credentials:
$client = new S3Client([ 'credentials' => [ 'key' => 'GOOGxxxxxxxxxxxxxxx', 'secret' => 'ZfcOTxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', ], 'region' => 'US', 'version' => 'latest', 'endpoint' => 'https://storage.googleapis.com', ]); try { $result = $client->putObject(array( 'Bucket' => 'devtest', 'Key' => 'test', 'Body' => 'Hello world' )); echo $result['ObjectURL']; } catch (\Aws\S3\Exception\S3Exception $e) {
Here is what I will return:
InvalidSecurity error executing "PutObject" on " https://storage.googleapis.com/devtest/test "; AWS HTTP error: client error response [url] https://storage.googleapis.com/devtest/test [status code] 403 [phrase reason] InvalidSecurity denied (client): security provided credentials are invalid. - InvalidSecurity The provided security credentials are invalid. Invalid authorization header
I tried searching through 100 different combinations of this problem and can't find anything. I have compatibility enabled, at least I think I'm doing it, because I don't think I can get the key / secret without turning it on first. And I have the Google Storage API enabled.
Any help would be greatly appreciated.
Edit: here is the authentication header in case this helps:
AWS4-HMAC-SHA256 Credential = GOOGGUxxxxxxxxxxx / 20150611 / USA / s3 / aws4_request, SignedHeaders = host; x-AMZ-content-sha256; x-AMZ-date, Signature = 9c7de4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I noticed that it remains “aws4_request” even when I specify “signature” => 'v2'. Not sure if this is important.
I took a look at the S3Client code and it does not use the “signature” configuration key, as far as I can tell. The only thing I found is "signature_version", which gets this error when installing on v2:
Unable to enable signature for v2 / s3 / US. Valid signature versions include v4 and anonymous.
I am using Laravel 5.1 with aws / aws-sdk-php composer version 3.0.3
Any ideas?