Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got this working, however, the code I used is not fundamentally different from the snippet you posted. Just in case you'd like to diff my version with yours, attached below is a complete copy of a Python program that worked for me. I initially got a 403, just like you, which was due to inheriting your project id :). After updating that value to use my project ID, I got a correct bucket listing. Two things to check:</p> <ol> <li><p>Make sure the project id you are using is correct and has the "Google Cloud Storage JSON API" enabled on the Google Developer Console "Services" tab (it's a different service from the other Google Cloud Storage API).</p></li> <li><p>Make sure you are loading the service accounts private key exactly as it came from the developer's console. I would recommend reading it into memory from the file you downloaded, as I've done here, rather than trying to copy it into a string literal in your code. </p></li> </ol> <hr> <pre><code>#!/usr/bin/env python import pprint import oauth2client from oauth2client.client import SignedJwtAssertionCredentials import httplib2 from apiclient.discovery import build f = open('key.p12', 'r') key = f.read() f.close() credentials = SignedJwtAssertionCredentials( 'REDACTED', 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="REDACTED") # Diagnostic pprint.pprint(request.headers) pprint.pprint(request.to_json()) # Do it! response = request.execute() pprint.pprint(response) </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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