Here is a precise problem I'd like to solve programmatically (e.g. not manually doing some actions by hand in a browser).
The machine has Google Cloud SDK installed.
The gsutil ls
command works successfully
However the python3 -c "from google.cloud import storage; storage.Client().list_buckets()"
fails:
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
I need to do something programmatically to make google.cloud.storage
work (using the credentials/auth mechanism used by gsutil). If gsutil
can access the credentials, then google.cloud.storage
should be able to do that as well.
How can I do that?
I probably need to set GOOGLE_APPLICATION_CREDENTIALS
to the JSON file that gsutil
is using, but what file does it use and are formats compatible?