App Engine accesses the Cloud Storage bucket using a service account, so likely that service account doesn't have write access to that bucket.
If you are accessing the default bucket (it appears you are, though the error message doesn't look like it), then the service account usually has access unless someone has revoked/changed that permission. You can repair your configuration using the Admin API repair method: https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps/repair You can use the form at the bottom of the page to invoke it. On Saturday, 3 December 2016 09:34:39 UTC-8, Mike Lucente wrote: > > I'm getting "Access Denied" trying to open a GCS file for writing. I'm > using these instructions: > https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/read-write-to-cloud-storage. > > Googling not helping much. Thanks in advance. > > Here's my code and the error: > > bucket_name = os.environ.get('BUCKET_NAME', > app_identity.get_default_gcs_bucket_name()) > filename = '/' + bucket_name + '/' + 'myfile' > print filename > gcs_file = gcs.open(filename, > 'w', > content_type='text/plain') > > ForbiddenError: Expect status [201] from Google Storage. But got status > 403. > Path: '/app_default_bucket/myfile'. > Request headers: {'accept-encoding': 'gzip, *', 'content-type': > 'text/plain', 'x-goog-api-version': '2', 'x-goog-resumable': 'start'}. > Response headers: {'server': 'UploadServer', 'vary': 'Origin', > 'content-length': '210', 'x-guploader-uploadid': > 'AEnB2UrEb9QG7lLMhN-Fu_kjPLbVwSuKfufgxIufy37ENZq0bK97IMaPdIuxA0ao4pTfuGAhZyi5hWzG5eqvBKEFk0nwheghJbkH4MlUSgFdKVzkFgt6rO8', > > 'content-type': 'application/xml; charset=UTF-8', 'alt-svc': 'quic=":443"; > ma=2592000; v="36,35,34"', 'date': 'Sat, 03 Dec 2016 17:33:41 GMT'}. > Body: "<?xml version='1.0' > encoding='UTF-8'?><Error><Code>AccessDenied</Code><Message>Access > denied.</Message><Details>Caller does not have storage.objects.create > access to bucket app_default_bucket.</Details></Error>". > Extra info: None. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at https://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/ff26fc16-b261-49f6-b461-f3eb480a2670%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.