File size: 1,921 Bytes
065fee7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
Configuration
*************
Overview
========
Use service client objects to configure your applications.
For example:
.. code-block:: python
>>> 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.
.. code-block:: python
>>> 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.
.. code-block:: python
>>> client.project
u'my-project'
Authentication
==============
The authentication credentials can be implicitly determined from the
environment or directly. See `Authentication <https://googleapis.dev/python/google-api-core/latest/auth.html#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.
.. code-block:: bash
$ gcloud config set project my-new-default-project
Environment Variables
=====================
.. automodule:: google.cloud.environment_vars
:members:
:show-inheritance:
|