@@ -89,6 +89,9 @@ If you have more than one plan, you can use `CredentialUtils` to get the service
8989
9090Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
9191
92+ - There are two ways of initializing an authenticator:
93+ 1 . Using the builder of the authenticator (builder pattern).
94+ 2 . Using the constructor of the authenticator (deprecated, but it is still available).
9295- With some service instances, you authenticate to the API by using ** [ IAM] ( #iam ) ** .
9396- In other instances, you authenticate by providing the ** [ username and password] ( #username-and-password ) ** for the service instance.
9497- If you're using a Watson service on Cloud Pak for Data, you'll need to authenticate in a [ specific way] ( #cloud-pak-for-data ) .
@@ -152,6 +155,18 @@ You supply either an IAM service **API key** or an **access token**:
152155
153156Supplying the IAM API key:
154157
158+ Builder pattern approach:
159+
160+ ``` java
161+ // letting the SDK manage the IAM token
162+ Authenticator authenticator = new IamAuthenticator .Builder ()
163+ .apikey(" <iam_api_key>" )
164+ .build();
165+ Discovery service = new Discovery (" 2019-04-30" , authenticator);
166+ ```
167+
168+ Deprecated constructor approach:
169+
155170``` java
156171// letting the SDK manage the IAM token
157172Authenticator authenticator = new IamAuthenticator (" <iam_api_key>" );
@@ -168,6 +183,18 @@ Discovery service = new Discovery("2019-04-30", authenticator);
168183
169184#### Username and password
170185
186+ Builder pattern approach:
187+
188+ ``` java
189+ Authenticator authenticator = new BasicAuthenticator .Builder ()
190+ .username(" <username>" )
191+ .password(" <password>" )
192+ .build();
193+ Discovery service = new Discovery (" 2019-04-30" , authenticator);
194+ ```
195+
196+ Deprecated constructor approach:
197+
171198``` java
172199Authenticator authenticator = new BasicAuthenticator (" <username>" , " <password>" );
173200Discovery service = new Discovery (" 2019-04-30" , authenticator);
@@ -190,6 +217,23 @@ service.configureClient(options);
190217#### Cloud Pak for Data
191218Like 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.
192219
220+ Builder pattern approach:
221+
222+ ``` java
223+ // letting the SDK manage the token
224+ Authenticator authenticator = new CloudPakForDataAuthenticator .Builder ()
225+ .url(" <CP4D token exchange base URL>" )
226+ .username(" <username>" )
227+ .password(" <password>" )
228+ .disableSSLVerification(true )
229+ .headers(null )
230+ .build();
231+ Discovery service = new Discovery (" 2019-04-30" , authenticator);
232+ service. setServiceUrl(" <service CP4D URL>" );
233+ ```
234+
235+ Deprecated constructor approach:
236+
193237``` java
194238// letting the SDK manage the token
195239Authenticator authenticator = new CloudPakForDataAuthenticator (
0 commit comments