Error using gcloud-golang storage lib to generate signed url?

569 views
Skip to first unread message

Kun Li

unread,
Dec 13, 2014, 4:44:43 PM12/13/14
to google-ap...@googlegroups.com
Hi:

I'm hosting my service on Appengine managed VM, one of the usage case of my service is that I need to generate some files for users, store it in Google Cloud Storage, and redirect user to the link of the files so that they can download them. i don't want to make the files to be public though, I want them to be available to user for a certain period of time.

I skimmed through the storage API provided in gcloud-golang library and figured signed URL would be what I want, however, I can not make it work, and my guess is that my SignedURLOptions is wrong.

In my signedURLOptions, I set 5 fields:

ClientID:   "clientID",
PrivateKey: key,
Method:     "GET",
Expires:     expires,
ContentType: "application/octet-stream",

clientID is what developer console shows to me, it's a service account. I then download the P12key, convert it to PEM file and use its content as key.

It generates a url for me, but whenever I open that url I get error message:

<Error>
<Code>InvalidAccessKeyId</Code>
<Message>
The User Id you provided does not exist in our records.
</Message>
</Error>

I also tried to put email email address, instead of client id, into "ClientID" field, and then I got

<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>
xxxxxxxxxxxxxxxx
</StringToSign>
</Error>


Any suggestions on how to address this error? Is there anything wrong in the step I use it?

Thanks!

Kun Li

unread,
Dec 16, 2014, 12:04:47 PM12/16/14
to google-ap...@googlegroups.com
Bump. Stuck on this one for a while. Any suggestions?

Andrew Greene

unread,
Dec 22, 2014, 9:32:26 PM12/22/14
to google-ap...@googlegroups.com
I don't know about the storage package, but this works:
Reply all
Reply to author
Forward
0 new messages