@@ -17,17 +17,34 @@ Setup
1717Authentication
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
3249Install 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.
0 commit comments