Skip to content

Commit a4c439e

Browse files
authored
Merge pull request watson-developer-cloud#743 from watson-developer-cloud/deprecate-cf-tokens
docs: add deprecation message for using watson-tokens
2 parents 41dda05 + de1b991 commit a4c439e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,12 +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-
242241
Note that the token is supplied URL-encoded, and will not be accepted if it is double-encoded in a querystring.
243242

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+
244246
```javascript
245247
var watson = require('watson-developer-cloud');
246248

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
247264
var authorization = new watson.AuthorizationV1({
248265
username: '<Text to Speech username>',
249266
password: '<Text to Speech password>',

lib/recognize-stream.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ class RecognizeStream extends Duplex {
181181
const options = this.options;
182182

183183
if (options.token && !options['watson-token']) {
184+
console.warn(
185+
'Authenticating with the X-Watson-Authorization-Token header or the `watson-token` query param is deprecated.' +
186+
' The token continues to work with Cloud Foundry services, but is not' +
187+
' supported for services that use Identity and Access Management (IAM) authentication.' +
188+
' For details see Authenticating with IAM tokens or the README in the IBM Watson SDK you use.'
189+
);
184190
options['watson-token'] = options.token;
185191
}
186192
if (options.content_type && !options['content-type']) {

0 commit comments

Comments
 (0)