Skip to content

Commit

Permalink
Updates readme template to show credential auth instead of api key. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gguuss authored and Jon Wayne Parrott committed Feb 14, 2017
1 parent d5d402d commit d4c18c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
37 changes: 26 additions & 11 deletions translate/cloud-client/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
++++++++++++++++++++
Expand Down Expand Up @@ -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}
...
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions translate/cloud-client/README.rst.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d4c18c4

Please sign in to comment.