- Notifications
You must be signed in to change notification settings - Fork95
docs: explain how to create credentials from dict#109
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
133 changes: 40 additions & 93 deletionsdocs/auth.rst
This file contains hidden or 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 |
|---|---|---|
| @@ -6,7 +6,11 @@ Authentication | ||
| Overview | ||
| ======== | ||
| For a language agnostic overview of authentication on Google Cloud, see `Authentication Overview`_. | ||
| .. _Authentication Overview: https://cloud.google.com/docs/authentication | ||
| * **If you're running in a Google Virtual Machine Environment (Compute Engine, App Engine, Cloud Run, Cloud Functions)**, | ||
| authentication should "just work". | ||
| * **If you're developing locally**, | ||
| @@ -41,7 +45,7 @@ Overview | ||
| $ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/keyfile.json" | ||
| .. _service account: https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating | ||
| Client-Provided Authentication | ||
| ============================== | ||
| @@ -97,11 +101,17 @@ After creation, you can pass it directly to a :class:`Client <google.cloud.clien | ||
| .. tip:: | ||
| To create a credentials object, follow the `google-auth-guide`_. | ||
| .. _google-auth-guide: https://googleapis.dev/python/google-auth/latest/user-guide.html#service-account-private-key-files | ||
| Google App Engine Standard First Generation Environment | ||
| ------------------------------------------------------- | ||
| These credentials are used only in the legacy Python 2.7 | ||
| `First Generation Standard Environment`_. All other App Engine | ||
| runtimes use Compute Engine credentials. | ||
| .. _First Generation Standard Environment: https://cloud.google.com/appengine/docs/standard/runtimes | ||
| To create | ||
| :class:`credentials <google.auth.app_engine.Credentials>` | ||
| @@ -115,9 +125,12 @@ just for Google App Engine: | ||
| Google Compute Engine Environment | ||
| --------------------------------- | ||
| These credentials are used in Google Virtual Machine Environments. | ||
| This includes most App Engine runtimes, Compute Engine, Cloud | ||
| Functions, and Cloud Run. | ||
| To create | ||
| :class:`credentials <google.auth.compute_engine.Credentials>`: | ||
| .. code:: python | ||
| @@ -129,16 +142,24 @@ Service Accounts | ||
| A `service account`_ is stored in a JSON keyfile. | ||
| .. code:: python | ||
| from google.oauth2 import service_account | ||
| credentials = service_account.Credentials.from_service_account_file( | ||
| '/path/to/key.json') | ||
| A JSON string or dictionary: | ||
| .. code:: python | ||
| import json | ||
| from google.oauth2 import service_account | ||
| json_account_info = json.loads(...) # convert JSON to dictionary | ||
| credentials = service_account.Credentials.from_service_account_info( | ||
| json_account_info) | ||
| .. tip:: | ||
| @@ -160,7 +181,7 @@ possible to call Google Cloud APIs with a user account via | ||
| A production application should **use a service account**, | ||
| but you may wish to use your own personal user account when first | ||
| getting started with the ``google-cloud-*`` library. | ||
| The simplest way to use credentials from a user account is via | ||
| Application Default Credentials using ``gcloud auth login`` | ||
| @@ -183,67 +204,10 @@ Troubleshooting | ||
| Setting up a Service Account | ||
| ---------------------------- | ||
| If your application is not running on a Google Virtual Machine Environment, | ||
| you need a Service Account. See `Creating a Service Account`_. | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This target is still referenced above. See thefailed docs build: Warning,treatedaserror:/tmpfs/src/github/python-api-core/docs/auth.rst:209:Unknowntargetname:"google developers service account".nox>Commandsphinx-build-W-T-N-bhtml-ddocs/_build/doctrees/docs/docs/_build/html/failedwithexitcode2 | ||
| .. _Creating a Service Account: https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating | ||
| Using Google Compute Engine | ||
| --------------------------- | ||
| @@ -262,24 +226,7 @@ you add the correct scopes for the APIs you want to access: | ||
| * ``https://www.googleapis.com/auth/cloud-platform`` | ||
| * ``https://www.googleapis.com/auth/cloud-platform.read-only`` | ||
| For scopes for specific APIs see `OAuth 2.0 Scopes for Google APIs`_ | ||
| .. _set up the GCE instance: https://cloud.google.com/compute/docs/authentication#using | ||
| .. _OAuth 2.0 Scopes for Google APIS: https://developers.google.com/identity/protocols/oauth2/scopes | ||
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.