I'm using this endpoint:
get_media(bucket=*, object=*, ifGenerationNotMatch=None, generation=None, ifMetagenerationMatch=None, ifGenerationMatch=None, ifMetagenerationNotMatch=None, projection=None)
which gives me the error:
apiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/storage/v1/b/my-logs/o/clickstream.1413365729497.log?alt=json returned "Insufficient Permission">
The code:
service = build('storage', 'v1')
contents = service.objects().get(bucket=item['bucket'], object=item['name']).execute(http=http)
The item is from a previous (successful) buckets.list call. Which is why the permission error for the service account is so strange.
This is currently on my localhost, and my authentication is:
with open(FILE_KEY, 'rb') as f:
key = f.read()
credentials = SignedJwtAssertionCredentials(
SERVICE_EMAIL_ADDRESS,
key,
scope='https://www.googleapis.com/auth/devstorage.full_control',
)
http = httplib2.Http()
http = credentials.authorize(http)
The objects (and new test objects I uploaded afterwards), are created with the default acl permissions. How come this doesn't work for a service account to retrieve the file contents?
Two things that may be interfering here:
Does your bucket ACL have the service account on it explicitly? Does the object? Is the service account listed in the bucket's default object ACL, so new objects written that don't otherwise override that ACL allow the service account to read it?
See also Access Control.
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