GCS Authentication issue

407 views
Skip to first unread message

Friso Kluit

unread,
Jun 27, 2019, 10:59:09 PM6/27/19
to Google App Engine
Using App Engine Python 2.7 Standard

Since about two hours, my operation to create a zip file on GCS is failing. Before this, it was working fine. 
The following line 

import cloudstorage as gcs
...
with gcs.open(new_zf.gcs_filename, 'w', content_type=b'multipart/x-zip',
                  options={b'x-goog-acl': b'public-read', b'cache-control': b'private, max-age=0, no-cache'}) as nzf:

triggers this error

<Error><Code>InvalidAuthentication</Code><Message>The provided authentication header is invalid.</Message><Details>Cannot use OAuth Authorization header with form POST.</Details></Error>". Extra info: None.

I have tried to change permissions on my roles on GCS from Storage Legacy Owner to Storage Admin

but I get a 'Sorry, there’s a problem. If you entered information, check it and try again. Otherwise, the problem might clear up on its own, so check back later.'  error

Amit Sinha

unread,
Jun 28, 2019, 2:56:23 PM6/28/19
to google-a...@googlegroups.com

Hello Friso,  


In a nutshell, it seems like an authentication issue. Are you using any browser along with this script call? If yes, could you try logged out from all browsers or clear all cache? You can also try to switch the bucket to see if it is specifically issue with the bucket you are using. I hope it helps.


Kyle Chessman

unread,
Jul 4, 2019, 5:18:14 PM7/4/19
to Google App Engine
I've been having the same problem since June 28. All other GCS operations have been continuing just fine.

Kyle Chessman

unread,
Jul 4, 2019, 7:58:03 PM7/4/19
to Google App Engine
I fixed this issue by removing the content_type argument in the open call. I'm not sure if this could cause any side effects but our task queue for zipping files cleared up with no problems.

We want to migrate to Python 3 in the future but the App Engine Cloud Storage library doesn't support Python 3 nor does it seem like it ever will ( https://github.com/GoogleCloudPlatform/appengine-gcs-client/issues/78 ). I wonder if zipping multiple files like this is still possible using the newer google-cloud-storage library.

Diogo Almeida

unread,
Jul 13, 2019, 4:52:32 PM7/13/19
to Google App Engine
By removing the content_type argument, Cloud Storage defaults to the type binary/octet-stream when it serves the object. 

In regards to Python 3.7, as per the documents [1][2] the Cloud Storage library is supported. However, I could not find how to zip multiple file in the documents. I suggest you take a look here and/or open a thread on Stack Overflow where other developers could provide some strategies on how to accomplish that.

Manabu SAITO

unread,
Aug 9, 2019, 12:01:29 AM8/9/19
to Google App Engine
I faced the same problem and solved it by the same way as yours. You saved me, thanks!

2019年7月5日金曜日 8時58分03秒 UTC+9 Kyle Chessman:
Reply all
Reply to author
Forward
0 new messages