I am trying to use "signed URLs" to access/upload files to Google Cloud Storage (GCS).
Followed the instructions at https://developers.google.com/storage/docs/accesscontrol#Signing-Strings
What I did:
However, I am still getting this (Status: 403 Forbidden):
<?xml version='1.0' encoding='UTF-8'?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message>
<StringToSign>PUT
text/plain
1384084959392
x-goog-api-version:2
x-goog-project-id:99999
/mybucket/myfile.txt</StringToSign>
</Error>
Even when I retry by signing the string based on values in "StringToSign", I still get the same error.
Read various related postings here but could not find any solution and most of it refers to x-goog-api-version:1
while i am using version 2.
What am i missing? Any help would be greatly appreciated.
Finally managed to PUT files to Google Cloud Storage using signed URLs. This was done by creating a simple Java program to simulate:
Server
to sign & encode a string as signature.Uploader
as an unauthenticated user submitting the PUT request using only the signature provided by Server
. Browser is simulated using Apache's HTTP Client library.You can see the demo app here.
I do not really understand why it did not work when I submitted through Chrome's Postman extension.
Though the doc says Content-Type
is optional, it actually means you must
set correct content-Type
correspond to your http request header.
In this case, your must add content-type: text/plain
in the signing string.
https://cloud.google.com/storage/docs/access-control/create-signed-urls-program
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With