@@ -19,7 +19,7 @@ Java client library to use the [Watson APIs][wdc].
1919 * [ Authentication] ( #authentication )
2020 * [ IAM] ( #iam )
2121 * [ Username and password] ( #username-and-password )
22- * [ API key ] ( #api-key )
22+ * [ ICP ] ( #icp )
2323 * [ Using the SDK] ( #using-the-sdk )
2424 * [ Parsing responses] ( #parsing-responses )
2525 * [ Configuring the HTTP client] ( #configuring-the-http-client )
@@ -184,6 +184,7 @@ Watson services are migrating to token-based Identity and Access Management (IAM
184184
185185- With some service instances, you authenticate to the API by using ** [ IAM] ( #iam ) ** .
186186- In other instances, you authenticate by providing the ** [ username and password] ( #username-and-password ) ** for the service instance.
187+ - If you're using a Watson service on ICP, you'll need to authenticate in a [ specific way] ( #icp ) .
187188
188189### Getting credentials
189190
@@ -245,55 +246,63 @@ You supply either an IAM service **API key** or an **access token**:
245246Supplying the IAM API key:
246247
247248``` java
248- // in the constructor, letting the SDK manage the IAM token
249+ // letting the SDK manage the IAM token
249250IamOptions options = new IamOptions .Builder ()
250251 .apiKey(" <iam_api_key>" )
251252 .url(" <iam_url>" ) // optional - the default value is https://iam.cloud.ibm.com/identity/token
252253 .build();
253254Discovery service = new Discovery (" 2017-11-07" , options);
254255```
255256
256- ``` java
257- // after instantiation, letting the SDK manage the IAM token
258- Discovery service = new Discovery (" 2017-11-07" );
259- IamOptions options = new IamOptions .Builder ()
260- .apiKey(" <iam_api_key>" )
261- .build();
262- service. setIamCredentials(options);
263- ```
264-
265257Supplying the access token:
266258
267259``` java
268- // in the constructor, assuming control of managing IAM token
260+ // assuming control of managing IAM token
269261IamOptions options = new IamOptions .Builder ()
270262 .accessToken(" <access_token>" )
271263 .build();
272264Discovery service = new Discovery (" 2017-11-07" , options);
273265```
274266
267+ #### Username and password
268+
275269``` java
276- // after instantiation, assuming control of managing IAM token
277- Discovery service = new Discovery ( " 2017-11-07 " );
278- IamOptions options = new IamOptions . Builder ( )
279- .accessToken (" <access_token> " )
270+ // in the constructor
271+ BasicAuthConfig config = new BasicAuthConfig . Builder ()
272+ .username( " <username> " )
273+ .password (" <password " )
280274 .build();
281- service. setIamCredentials(options );
275+ Discovery service = new Discovery ( " 2017-11-07 " , config );
282276```
283277
284- #### Username and password
278+ #### ICP
279+ Like IAM, you can pass in credentials to let the SDK manage an access token for you or directly supply an access token to do it yourself.
285280
286281``` java
287- // in the constructor
288- Discovery service = new Discovery (" 2017-11-07" , " <username>" , " <password>" );
282+ // letting the SDK manage the token
283+ ICP4DConfig config = new ICP4DConfig .Builder ()
284+ .url(" <ICP token exchange base URL>" )
285+ .username(" <username>" )
286+ .password(" <password>" )
287+ .disableSSLVerification(true )
288+ .build();
289+ Discovery service = new Discovery (" 2017-11-07" , config);
290+ service. setEndPoint(" <service ICP URL>" );
289291```
290292
291293``` java
292- // after instantiation
293- Discovery service = new Discovery (" 2017-11-07" );
294- service. setUsernameAndPassword(" <username>" , " <password>" );
294+ // letting the SDK manage the token
295+ ICP4DConfig config = new ICP4DConfig .Builder ()
296+ .url(" <ICP token exchange base URL>" )
297+ .userManagedAccessToken(" <access token>" )
298+ .disableSSLVerification(true )
299+ .build();
300+ Discovery service = new Discovery (" 2017-11-07" , config);
301+ service. setEndPoint(" <service ICP URL>" );
295302```
296303
304+ Be sure to both disable SSL verification when authenticating and set the endpoint explicitly to the URL given in ICP.
305+
297306## Using the SDK
298307
299308### Parsing responses
0 commit comments