I've have a bucket at a url something like: https://console.developers.google.com/storage/browser/gdfp-1234/
Then I created a project, named something like 'api-required' so I could generate credentials at /apis/credentials?project=api-required
Then, I generated a json service account key with the new_credentials
button at /api/credentials/
. I saved the json object I downloaded to a file that I pointed my environment variable GOOGLE_APPLICATION_CREDENTIALS
at.
Now, I'm building an application in python. This code:
from gcloud import storage
gcs = storage.Client(project='my client n')
bucket = gcs.get_bucket(bucket_name)
Gives me a 403 Forbidden
error.
Google Cloud Storage JSON API
is in the Enabled API's list in the API Manager. This seems to cover everything in the docs.
I've been pouring over the docs, and cannot for the life of me figure out what I am doing wrong. Any help figuring this out would be greatly appreciated, thanks!
EDIT:
Here's the traceback:
/Users/asdf/.virtualenvs/analytics_pipeline/lib/python2.7/site-packages/gcloud/storage/client.pyc in get_bucket(self, bucket_name)
165 """
166 bucket = Bucket(self, name=bucket_name)
--> 167 bucket.reload(client=self)
168 return bucket
169
/Users/asdf/.virtualenvs/analytics_pipeline/lib/python2.7/site-packages/gcloud/storage/_helpers.pyc in reload(self, client)
75 api_response = client.connection.api_request(
76 method='GET', path=self.path, query_params=query_params,
---> 77 _target_object=self)
78 self._set_properties(api_response)
79
/Users/asdf/.virtualenvs/analytics_pipeline/lib/python2.7/site-packages/gcloud/connection.pyc in api_request(self, method, path, query_params, data, content_type, api_base_url, api_version, expect_json, _target_object)
335 if not 200 <= response.status < 300:
336 raise make_exception(response, content,
--> 337 error_info=method + ' ' + url)
338
339 string_or_bytes = (six.binary_type, six.text_type)
So the bucket was accessible by a google group I belonged to, and the bucket was created by DFP because the bucket was full of DFP Data Transfer Files/Reports. To access their bucket, I had to add the email found in the json file I downloaded to the google group (Using the add member direct button, not the invite button). Once I added them to the google group everything worked like a charm.
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