Configuration

Overview

Use service client objects to configure your applications.

For example:

>>> from google.cloud import bigquery
>>> client = bigquery.Client()

When creating a client in this way, the project ID will be determined by searching these locations in the following order.

  • GOOGLE_CLOUD_PROJECT environment variable

  • GOOGLE_APPLICATION_CREDENTIALS JSON file

  • Default service configuration path from $ gcloud beta auth application-default login.

  • Google App Engine application ID

  • Google Compute Engine project ID (from metadata server)

You can override the detection of your default project by setting the

`project` parameter when creating client objects.
>>> from google.cloud import bigquery
>>> client = bigquery.Client(project='my-project')

You can see what project ID a client is referencing by accessing the project property on the client object.

>>> client.project
u'my-project'

Authentication

The authentication credentials can be implicitly determined from the environment or directly. See Authentication.

Logging in via gcloud beta auth application-default login will automatically configure a JSON key file with your default project ID and credentials.

Setting the GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PROJECT environment variables will override the automatically configured credentials.

You can change your default project ID to my-new-default-project by using the gcloud CLI tool to change the configuration.

$ gcloud config set project my-new-default-project

Environment Variables

Comprehensive list of environment variables used in google-cloud.

These enable many types of implicit behavior in both production and tests.

google.cloud.environment_vars.BIGTABLE_EMULATOR( = 'BIGTABLE_EMULATOR_HOST )

Environment variable defining host for Bigtable emulator.

google.cloud.environment_vars.DISABLE_GRPC( = 'GOOGLE_CLOUD_DISABLE_GRPC )

Environment variable acting as flag to disable gRPC.

To be used for APIs where both an HTTP and gRPC implementation exist.

google.cloud.environment_vars.GCD_DATASET( = 'DATASTORE_DATASET )

Environment variable defining default dataset ID under GCD.

google.cloud.environment_vars.GCD_HOST( = 'DATASTORE_EMULATOR_HOST )

Environment variable defining host for GCD dataset server.

google.cloud.environment_vars.PUBSUB_EMULATOR( = 'PUBSUB_EMULATOR_HOST )

Environment variable defining host for Pub/Sub emulator.