Content-Length: 410435 | pFad | http://github.com/googleapis/google-cloud-python/commit/69cfaea0a0f5adee6865944058bd42536a05aee3

D8 Updates readme template to show credential auth instead of api key. [… · googleapis/google-cloud-python@69cfaea · GitHub
Skip to content

Commit 69cfaea

Browse files
gguussdanoscarmike
authored andcommitted
Updates readme template to show credential auth instead of api key. [(#802)](GoogleCloudPlatform/python-docs-samples#802)
1 parent aaf8c66 commit 69cfaea

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

packages/google-cloud-translate/samples/snippets/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.

packages/google-cloud-translate/samples/snippets/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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-python/commit/69cfaea0a0f5adee6865944058bd42536a05aee3

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy