From 50695482e8f50109aead04000f0215b98638a391 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 13 Feb 2017 16:18:09 -0800 Subject: [PATCH] Updates readme template to show credential auth instead of api key. --- translate/cloud-client/README.rst | 37 +++++++++++++++++++--------- translate/cloud-client/README.rst.in | 4 +-- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/translate/cloud-client/README.rst b/translate/cloud-client/README.rst index fc4e87d0522a..05067d64c17d 100644 --- a/translate/cloud-client/README.rst +++ b/translate/cloud-client/README.rst @@ -17,17 +17,34 @@ Setup Authentication ++++++++++++++ -Authentication for this service is done via an `API Key`_. To obtain an API -Key: +Authentication is typically done through `Application Default Credentials`_, +which means you do not have to change the code to authenticate as long as +your environment has credentials. You have a few options for setting up +authentication: -1. Open the `Cloud Platform Console`_ -2. Make sure that billing is enabled for your project. -3. From the **Credentials** page, create a new **API Key** or use an existing - one for your project. +#. When running locally, use the `Google Cloud SDK`_ -.. _API Key: - https://developers.google.com/api-client-library/python/guide/aaa_apikeys -.. _Cloud Console: https://console.cloud.google.com/project?_ + .. code-block:: bash + + gcloud beta auth application-default login + + +#. When running on App Engine or Compute Engine, credentials are already + set-up. However, you may need to configure your Compute Engine instance + with `additional scopes`_. + +#. You can create a `Service Account key file`_. This file can be used to + authenticate to Google Cloud Platform services from any environment. To use + the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to + the path to the key file, for example: + + .. code-block:: bash + + export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json + +.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow +.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using +.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount Install Dependencies ++++++++++++++++++++ @@ -77,7 +94,6 @@ To run this sample: $ python snippets.py usage: snippets.py [-h] - api_key {detect-language,list-languages,list-languages-with-target,translate-text} ... @@ -88,7 +104,6 @@ To run this sample: https://cloud.google.com/translate/docs. positional arguments: - api_key Your API key. {detect-language,list-languages,list-languages-with-target,translate-text} detect-language Detects the text's language. list-languages Lists all available languages. diff --git a/translate/cloud-client/README.rst.in b/translate/cloud-client/README.rst.in index 6ac89da13ac8..0fe2a3399433 100644 --- a/translate/cloud-client/README.rst.in +++ b/translate/cloud-client/README.rst.in @@ -4,12 +4,12 @@ product: name: Google Translate API short_name: Translate API url: https://cloud.google.com/translate/docs - description: > + description: > With `Google Translate API`, you can dynamically translate text between thousands of language pairs. setup: -- auth_api_key +- auth - install_deps samples: