-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get project ID from JSON credentials file (#1813)
* Add project ID from credentials file.
- Loading branch information
1 parent
5fc0c01
commit 4cf311b
Showing
4 changed files
with
220 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Configuration | ||
************* | ||
|
||
Overview | ||
======== | ||
|
||
Use service client objects to configure your applications. | ||
|
||
For example: | ||
|
||
.. code-block:: python | ||
>>> from gcloud 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. | ||
|
||
* GCLOUD_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 gcloud 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 :doc:`gcloud-auth`. | ||
|
||
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 ``GCLOUD_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
:caption: gcloud | ||
|
||
gcloud-api | ||
gcloud-config | ||
gcloud-auth | ||
|
||
.. toctree:: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.