Skip to content

Commit de1b991

Browse files
committed
docs: provide iam example for auth service
1 parent 820ed31 commit de1b991

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,29 @@ If you are having difficulties using the APIs or have a question about the Watso
238238
The Authorization service can generate auth tokens for situations where providing the service username/password is undesirable.
239239

240240
Tokens are valid for 1 hour and may be sent using the `X-Watson-Authorization-Token` header or the `watson-token` query param.
241-
242-
> _NOTE_: Authenticating with the `X-Watson-Authorization-Token` header is now deprecated. The token continues to work with Cloud Foundry services, but is not supported for services that use Identity and Access Management (IAM) authentication. For details see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html#iam) or the README in the IBM Watson SDK you use.
243-
244241
Note that the token is supplied URL-encoded, and will not be accepted if it is double-encoded in a querystring.
245242

243+
> _NOTE_: Authenticating with the `X-Watson-Authorization-Token` header or the `watson-token` query param is now deprecated. The token continues to work with Cloud Foundry services, but is not supported for services that use Identity and Access Management (IAM) authentication. For details see [Authenticating with IAM tokens](https://console.bluemix.net/docs/services/watson/getting-started-iam.html#iam) or the README in the IBM Watson SDK you use.
244+
The Authorization SDK now supports returning IAM Access Tokens when instantiated with an IAM API key.
245+
246246
```javascript
247247
var watson = require('watson-developer-cloud');
248248

249+
// to get an IAM Access Token
250+
var authorization = new watson.AuthorizationV1({
251+
iam_apikey: '<Service API key>',
252+
iam_url: '<IAM endpoint URL - OPTIONAL>',
253+
});
254+
255+
authorization.getToken(function (err, token) {
256+
if (!token) {
257+
console.log('error:', err);
258+
} else {
259+
// Use your token here
260+
}
261+
});
262+
263+
// to get a Watson Token - NOW DEPRECATED
249264
var authorization = new watson.AuthorizationV1({
250265
username: '<Text to Speech username>',
251266
password: '<Text to Speech password>',

lib/recognize-stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class RecognizeStream extends Duplex {
182182

183183
if (options.token && !options['watson-token']) {
184184
console.warn(
185-
'Authenticating with the X-Watson-Authorization-Token header is deprecated.' +
185+
'Authenticating with the X-Watson-Authorization-Token header or the `watson-token` query param is deprecated.' +
186186
' The token continues to work with Cloud Foundry services, but is not' +
187187
' supported for services that use Identity and Access Management (IAM) authentication.' +
188188
' For details see Authenticating with IAM tokens or the README in the IBM Watson SDK you use.'

0 commit comments

Comments
 (0)