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
***speech-to-text:** optional parameter `force` added to the method `upgradeAcousticModel` ([ceaa843](https://github.com/watson-developer-cloud/node-sdk/commit/ceaa843))
Copy file name to clipboardExpand all lines: README.md
+48-7Lines changed: 48 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,14 +86,55 @@ Watson services are migrating to token-based Identity and Access Management (IAM
86
86
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
87
87
88
88
### Getting credentials
89
+
89
90
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:
90
91
91
-
1. Go to the IBM Cloud [Dashboard](https://console.bluemix.net/dashboard/apps?category=ai) page.
92
-
1. Either click an existing Watson service instance or click [**Create resource > AI**](https://console.bluemix.net/catalog/?category=ai) and create a service instance.
93
-
1. Click **Show** to view your service credentials.
94
-
1. Copy the `url` and either `apikey` or `username` and `password`.
92
+
1. Go to the IBM Cloud [Dashboard](https://cloud.ibm.com/) page.
93
+
2. Either click an existing Watson service instance in your [resource list](https://cloud.ibm.com/resources) or click [**Create resource > AI**](https://cloud.ibm.com/catalog?category=ai) and create a service instance.
94
+
3. Click on the **Manage** item in the left nav bar of your service instance.
95
+
96
+
On this page, you should be able to see your credentials for accessing your service instance.
97
+
98
+
In your code, you can use these values in the service constructor or with a method call after instantiating your service.
99
+
100
+
### Supplying credentials
101
+
102
+
There are two ways to supply the credentials you found above to the SDK for authentication:
103
+
104
+
#### Credentials file (easier!)
105
+
106
+
With a credentials file, you just need to put the file in the right place and the SDK will do the work of parsing it and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance.
107
+
108
+
The file downloaded will be called `ibm-credentials.env`. This is the name the SDK will search for and **must** be preserved unless you want to configure the file path (more on that later). The SDK will look for your `ibm-credentials.env` file in the following places (in order):
109
+
110
+
- Directory provided by the environment variable `IBM_CREDENTIALS_FILE`
111
+
- Your system's home directory
112
+
- Your current working directory (the directory Node is executed from)
113
+
114
+
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services.
124
+
125
+
If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that:
126
+
127
+
```bash
128
+
export IBM_CREDENTIALS_FILE="<path>"
129
+
```
130
+
131
+
where `<path>` is something like `/home/user/Downloads/<file_name>.env`. If you just provide a path to a directory, the SDK will look for a file called `ibm-credentials.env` in that directory.
132
+
133
+
#### Manually
134
+
135
+
The SDK also supports setting credentials manually in your code. You will either use IAM credentials or Basic Authentication (username/password) credentials.
95
136
96
-
### IAM
137
+
#####IAM
97
138
98
139
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.
99
140
@@ -102,7 +143,7 @@ You supply either an IAM service **API key** or an **access token**:
102
143
- 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.
103
144
- 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.
104
145
105
-
#### Supplying the IAM API key
146
+
######Supplying the IAM API key
106
147
107
148
```js
108
149
// in the constructor, letting the SDK manage the IAM token
@@ -114,7 +155,7 @@ const discovery = new DiscoveryV1({
114
155
});
115
156
```
116
157
117
-
#### Supplying the access token
158
+
######Supplying the access token
118
159
119
160
```js
120
161
// in the constructor, assuming control of managing IAM token
Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# Upgrading to watson-developer-cloud@4.0
2
2
-[Breaking changes]
3
+
-[Methods no longer return stream]
4
+
-[Error Handling Compatibility]
3
5
-[Removed Services]
4
6
-[Constructor Compatibility]
5
7
-[Discovery Compatibility]
@@ -12,6 +14,21 @@
12
14
13
15
14
16
## Breaking changes
17
+
### Methods no longer return stream
18
+
Previously, if a callback was not provided, each service method would return a pipeable stream. Now, this will no longer happen. This should not affect many users, as authenticating with IAM already prevented methods from returning streams.
19
+
20
+
### Error Handling Compatibility
21
+
The logic that formats errors returned from a service has been changed. That means that the Error object returned now has a different structure. If there is logic in your code that parses the error returned from service methods, this will need to change. The new structure is outlined below.
22
+
23
+
The object returned is of class `Error` and has the following properties:
24
+
-`name`: Short title describing the error. Ex) 'Not Found'
25
+
-`code`: HTTP status code. Ex) 404
26
+
-`message`: More descriptive error message. Ex) Model not found.
27
+
-`body`: Full error object returned by the service, stringified. If the object cannot be stringified due to a circular reference, it will be left as an object
28
+
-`headers`: Object containing response headers returned from the service, including the transaction id
29
+
30
+
If a request is made but no response is received (very rare), `error.body` will be an instance of [HTTP.ClientRequest](https://nodejs.org/api/http.html#http_class_http_clientrequest).
31
+
15
32
### Removed Services
16
33
The following services have been deprecated for an extended period of time and will no longer be supported in the SDK:
0 commit comments