Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot get service account authorization to work on GCS script using Python client lib APIs
    primarykey
    data
    text
    <p>In attempting to write a python script to access GCS using service-based authorization, I have come up with the following. Note that 'key' is the contents of my p12 file.</p> <p>I am attempting to just read the list of buckets on my account. I have successfully created one bucket using the web interface to GCS, and can see that with gsutil. </p> <p>When I execute the code below I get a 403 error. At first I thought I was not authorized correctly, but I tried from this very useful web page (which uses web-based authorization), and it works correctly. <a href="https://developers.google.com/apis-explorer/#p/storage/v1beta1/storage.buckets.list?projectId=" rel="nofollow">https://developers.google.com/apis-explorer/#p/storage/v1beta1/storage.buckets.list?projectId=</a>&amp;_h=2&amp;</p> <p>When I look at the headers and query string and compare them to the keaders and query of the website-generated request I see that there is no authorization header, and that there is no key= tag in the query string. I suppose I thought that the credential authorization would have taken care of this for me. </p> <p>What am I doing wrong?</p> <p>code:</p> <pre><code>credentials = SignedJwtAssertionCredentials( 'xxx-my-long-email-from-the-console@developer.gserviceaccount.com', key, scope='https://www.googleapis.com/auth/devstorage.full_control') http = httplib2.Http() http = credentials.authorize(http) service = build("storage", "v1beta1", http=http) # Build the request request = service.buckets().list(projectId="159910083329") # Diagnostic pprint.pprint(request.headers) pprint.pprint(request.to_json()) # Do it! response = request.execute() </code></pre> <p>When I try to execute I get the 403. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload