Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4c18c4

Browse files
gguussJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
Updates readme template to show credential auth instead of api key. (GoogleCloudPlatform#802)
1 parent d5d402d commit d4c18c4

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

translate/cloud-client/README.rst

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,34 @@ Setup
1717
Authentication
1818
++++++++++++++
1919

20-
Authentication for this service is done via an `API Key`_. To obtain an API
21-
Key:
20+
Authentication is typically done through `Application Default Credentials`_,
21+
which means you do not have to change the code to authenticate as long as
22+
your environment has credentials. You have a few options for setting up
23+
authentication:
2224

23-
1. Open the `Cloud Platform Console`_
24-
2. Make sure that billing is enabled for your project.
25-
3. From the **Credentials** page, create a new **API Key** or use an existing
26-
one for your project.
25+
#. When running locally, use the `Google Cloud SDK`_
2726

28-
.. _API Key:
29-
https://developers.google.com/api-client-library/python/guide/aaa_apikeys
30-
.. _Cloud Console: https://console.cloud.google.com/project?_
27+
.. code-block:: bash
28+
29+
gcloud beta auth application-default login
30+
31+
32+
#. When running on App Engine or Compute Engine, credentials are already
33+
set-up. However, you may need to configure your Compute Engine instance
34+
with `additional scopes`_.
35+
36+
#. You can create a `Service Account key file`_. This file can be used to
37+
authenticate to Google Cloud Platform services from any environment. To use
38+
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
39+
the path to the key file, for example:
40+
41+
.. code-block:: bash
42+
43+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
44+
45+
.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
46+
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
47+
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
3148

3249
Install Dependencies
3350
++++++++++++++++++++
@@ -77,7 +94,6 @@ To run this sample:
7794
$ python snippets.py
7895
7996
usage: snippets.py [-h]
80-
api_key
8197
{detect-language,list-languages,list-languages-with-target,translate-text}
8298
...
8399
@@ -88,7 +104,6 @@ To run this sample:
88104
https://cloud.google.com/translate/docs.
89105
90106
positional arguments:
91-
api_key Your API key.
92107
{detect-language,list-languages,list-languages-with-target,translate-text}
93108
detect-language Detects the text's language.
94109
list-languages Lists all available languages.

translate/cloud-client/README.rst.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ product:
44
name: Google Translate API
55
short_name: Translate API
66
url: https://cloud.google.com/translate/docs
7-
description: >
7+
description: >
88
With `Google Translate API`, you can dynamically translate text between
99
thousands of language pairs.
1010

1111
setup:
12-
- auth_api_key
12+
- auth
1313
- install_deps
1414

1515
samples:

0 commit comments

Comments
 (0)