Authenticating to the Google Cloud

If you want to work with Big Query you need to authenticate to the Google Cloud. BigQuery is a Google Cloud data warehouse.

You do this by running this command from the command line. The shell will open the browser then ask you to login to Google. It will then save credentials on your laptop. When you create the Session object with the API Google will know where to read that session from. It will also use those credentials when you use the Google cloud command-line tool gsutil.

 gcloud auth application-default login

Big Query Python Example

Here is a Python example showing how to use those Google credentials.

Install the SDK and Python package:

brew install google-cloud-sdk
pip install google-cloud-storage

Python Example

In this Python example we give it the name of project. Or you can put None.

from import storage

storage_client = storage.Client("ecstatic-doodad-203713")
buckets = storage_client.list_buckets()

for bucket in buckets:

Google Cloud Command Line Utility Example

Here is an example using the Google Cloud Command Line Utility. It lists Storage buckets in a project:

gsutil ls -p ecstatic-doodad-203713