You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: branches/tswast-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/translate/snippets/DetectLanguageAndTranslate.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,8 @@ public class DetectLanguageAndTranslate {
36
36
37
37
publicstaticvoidmain(String... args) {
38
38
// Create a service object
39
-
// API key is read from the GOOGLE_API_KEY environment variable
39
+
// Default application credentials or an API key from the GOOGLE_API_KEY environment variable
Copy file name to clipboardExpand all lines: branches/tswast-patch-1/google-cloud-translate/README.md
+20-11Lines changed: 20 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,20 +64,25 @@ Getting Started
64
64
---------------
65
65
#### Prerequisites
66
66
For this tutorial, you need a [Google Developers Console](https://console.developers.google.com/)
67
-
project with "Translate API" enabled via the console's API Manager. You will also need a to enable
68
-
billing via the [Google Developers Console](https://console.developers.google.com/) project and to
69
-
retrieve an API key. See [Translate quickstart](https://cloud.google.com/translate/v2/quickstart)
70
-
for more details.
67
+
project with "Translate API" enabled via the console's API Manager. You also need to enable
68
+
billing via the [Google Developers Console](https://console.developers.google.com/).
69
+
70
+
Finally, you must set up the local development environment by
71
+
[installing the Google Cloud SDK](https://cloud.google.com/sdk/) and running the following command
72
+
in command line: `gcloud auth application-default login`. Alternatively, you can authenticate
73
+
Translate requests using an API key. See
74
+
[Translate quickstart](https://cloud.google.com/translate/v2/quickstart) for more details.
71
75
72
76
#### Installation and setup
73
77
You'll need to obtain the `google-cloud-translate` library. See the [Quickstart](#quickstart)
74
78
section to add `google-cloud-translate` as a dependency in your code.
75
79
76
80
#### Creating an authorized service object
77
-
To make authenticated requests to Google Translates, you must create a service object with an API
78
-
key. By default, API key is looked for in the `GOOGLE_API_KEY` environment variable. Once the API
79
-
key is set, you can make API calls by invoking methods on the Translate service object. To create a
80
-
service object, given that `GOOGLE_API_KEY` is set, use the following code:
81
+
To make authenticated requests to Google Translate, you must create a service object with
82
+
credentials or with an API key. The simplest way to authenticate is to use
Copy file name to clipboardExpand all lines: branches/tswast-patch-1/google-cloud-translate/src/main/java/com/google/cloud/translate/TranslateOptions.java
Copy file name to clipboardExpand all lines: branches/tswast-patch-1/google-cloud-translate/src/main/java/com/google/cloud/translate/spi/DefaultTranslateRpc.java
Copy file name to clipboardExpand all lines: branches/tswast-patch-1/google-cloud-translate/src/main/java/com/google/cloud/translate/spi/TranslateRpc.java
0 commit comments