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
In your code, you can use these values in the service constructor or with a method call after instantiating your service. Here are some examples:
142
-
143
-
### Username and Password
134
+
Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
144
135
145
-
```java
146
-
// in the constructor
147
-
Discovery service =newDiscovery("2017-11-07", "<username>", "<password>");
148
-
```
136
+
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
137
+
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
138
+
- Visual Recognition uses a form of [API key](#api-key) only with instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services:
155
142
156
-
### API Key
143
+
1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page.
144
+
1. Either click an existing Watson service instance or click **Create**.
145
+
1. Click **Show** to view your service credentials.
146
+
1. Copy the `url` and either `apikey` or `username` and `password`.
157
147
158
-
_Important: Instantiation with API key works only with Visual Recognition service instances created before May 23, 2018. Visual Recognition instances created after May 22 use IAM._
148
+
In your code, you can use these values in the service constructor or with a method call after instantiating your service.
159
149
160
-
```java
161
-
// in the constructor
162
-
VisualRecognition service =newVisualRecognition("2016-05-20", "<api_key>");
163
-
```
150
+
### IAM
164
151
165
-
```java
166
-
// after instantiation
167
-
VisualRecognition service =newVisualRecognition("2016-05-20");
168
-
service.setApiKey("<api_key>");
169
-
```
152
+
Some services use token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated.
170
153
171
-
### Using IAM
154
+
You supply either an IAM service **API key** or an **access token**:
172
155
173
-
When authenticating with IAM, you have the option of passing in:
174
-
- the IAM API key and, optionally, the IAM service URL
175
-
- an IAM access token
156
+
- Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary.
157
+
- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html). If you want to switch to API key, override your stored IAM credentials with an IAM API key. Then call the `setIamCredentials()` method again.
176
158
177
-
**Be aware that passing in an access token means that you're assuming responsibility for maintaining that token's lifecycle.** If you instead pass in an IAM API key, the SDK will manage it for you.
178
159
160
+
#### Supplying the IAM API key
179
161
```java
180
162
// in the constructor, letting the SDK manage the IAM token
181
163
IamOptions options =newIamOptions.Builder()
@@ -194,6 +176,7 @@ IamOptions options = new IamOptions.Builder()
194
176
service.setIamCredentials(options);
195
177
```
196
178
179
+
#### Supplying the access token
197
180
```java
198
181
// in the constructor, assuming control of managing IAM token
199
182
IamOptions options =newIamOptions.Builder()
@@ -211,13 +194,39 @@ IamOptions options = new IamOptions.Builder()
211
194
service.setIamCredentials(options);
212
195
```
213
196
214
-
If at any time you would like to let the SDK take over managing your IAM token, simply override your stored IAM credentials with an IAM API key by calling the `setIamCredentials()` method again.
197
+
### Username and password
198
+
199
+
```java
200
+
// in the constructor
201
+
Discovery service =newDiscovery("2017-11-07", "<username>", "<password>");
**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
213
+
214
+
```java
215
+
// in the constructor
216
+
VisualRecognition service =newVisualRecognition("2016-05-20", "<api_key>");
217
+
```
218
+
219
+
```java
220
+
// after instantiation
221
+
VisualRecognition service =newVisualRecognition("2016-05-20");
222
+
service.setApiKey("<api_key>");
223
+
```
215
224
216
225
## Android
217
226
218
227
The Android SDK utilizes the Java SDK while making some Android-specific additions. This repository can be found [here](https://github.com/watson-developer-cloud/android-sdk). It depends on [OkHttp][] and [gson][].
219
228
220
-
## Using a Proxy
229
+
## Using a proxy
221
230
222
231
Override the `configureHttpClient()` method and add the proxy using the `OkHttpClient.Builder` object.
Custom headers can be passed with any request. To do so, add the header to the `ServiceCall` object before executing the request. For example, this is what it looks like to send the header `Custom-Header` along with a call to the Watson Assistant service:
The basic `execute()`, `enqueue()`, and `rx()` methods make HTTP requests to your Watson service and return models based on the requested endpoint. If you would like access to some HTTP response information along with the response model, you can use the more detailed versions of those three methods: `executeWithDetails()`, `enqueueWithDetails()`, and `rxWithDetails()`. To capture the responses, use the new `Response<T>` class, with `T` being the expected response model.
Make sure you are using the service credentials and not your IBM Cloud account/password.
323
-
Check the API Endpoint, you may need to update the default using `setEndPoint()`.
332
+
Check the API endpoint, you may need to update the default using `setEndPoint()`.
324
333
325
334
## Changes for v4.0
326
335
Version 4.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/java-sdk/wiki/Changelog) for the details. This version also includes many breaking changes as a result of standardizing behavior across the new generated services. Full details on migration from previous versions can be found [here](https://github.com/watson-developer-cloud/java-sdk/wiki/Migration).
@@ -356,7 +365,7 @@ INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/di
356
365
357
366
**Warning:** The logs generated by this logger when using the level `FINE` or `ALL` has the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the contents of request and response bodies. This data should only be logged in a controlled way or in a non-production environment.
358
367
359
-
## Build + Test
368
+
## Build + test
360
369
361
370
To build and test the project you can use [Gradle][] (version 1.x).
362
371
@@ -381,7 +390,7 @@ gradle idea # Intellij IDEA
381
390
gradle eclipse # Eclipse
382
391
```
383
392
384
-
## Open Source @ IBM
393
+
## Open source @ IBM
385
394
386
395
Find more open source projects on the [IBM Github Page](http://ibm.github.io/)
387
396
@@ -394,7 +403,7 @@ available in [LICENSE](LICENSE).
394
403
395
404
See [CONTRIBUTING.md](.github/CONTRIBUTING.md).
396
405
397
-
## Code of Conduct
406
+
## Code of conduct
398
407
399
408
See [CODE_OF_CONDUCT.md](.github/CODE_OF_CONDUCT.md).
400
409
@@ -408,12 +417,14 @@ or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson).
Copy file name to clipboardExpand all lines: language-translator/README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,8 @@
1
1
# Language Translator
2
2
3
+
## Deprecation notice
4
+
Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information.
Copy file name to clipboardExpand all lines: language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java
0 commit comments