Search code examples
pythoncurloauth-2.0google-oauthgoogle-cloud-storage

Non-interactive access to google cloud storage


I would like to use only http calls (e.g., with curl) to make authenticated calls to the google cloud storage API.

Using the google dev console, I have enabled the API and downloaded three created sets of credential information. These information JSON files have the following fields:

  • ['token_uri', 'client_secret', 'client_id', 'auth_uri', 'project_id', 'auth_provider_x509_cert_url', 'redirect_uris'] within 'installed' field
  • ['token_uri', 'client_email', 'client_id', 'client_x509_cert_url', 'auth_uri', 'project_id', 'type', 'auth_provider_x509_cert_url', 'private_key', 'private_key_id']
  • ['project_id', 'token_uri', 'client_id', 'auth_provider_x509_cert_url', 'auth_uri'] within 'installed' field

What sequence of calls do I need to make? It can be assumed that the username/password are available for a user with access to the datastore .

(I believe this must be documented here on SO or elsewhere, but I am having no luck finding anything.)


Solution

  • In the end, I followed my intuition, and have wrapped the resulting code in my project GCSFS, specifically here which can take either the device code route (requires the user to interact with the browser), accepts a refresh token by any means, or accepts a google credential file of the sort produced by logging in with gcloud.