-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get project ID from JSON credentials file #1813
Merged
daspecster
merged 13 commits into
googleapis:master
from
daspecster:project-id-from-credentials-file
Jun 16, 2016
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a437715
Add project ID from credentials.
daspecster 67a4b54
Update docs mentioning default project.
daspecster 078220c
Add context file handling, fix no env test.
daspecster 2fdbfa4
add gcloud-config.rst
daspecster ceeaddf
Add Docs and Service account project ID
daspecster efdfa92
Switch to Popen for py26
daspecster 8824015
Capture gcloud info output
daspecster b57cf8d
Use constant for project key.
daspecster 72d7288
Get project ID from default configuration file
daspecster c75e9b2
Feedback updates
daspecster cf419e6
Update docs and json file handling
daspecster d7b1951
Update with new authentication CLI command
daspecster 3f408c1
Add win32 path for config
daspecster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.