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
@@ -103,9 +105,9 @@ On this page, you should be able to see your credentials for accessing your serv
103
105
104
106
### Supplying credentials
105
107
106
-
There are two ways to supply the credentials you found above to the SDK for authentication.
108
+
There are three ways to supply the credentials you found above to the SDK for authentication.
107
109
108
-
#### Credential file (easier!)
110
+
#### Credential file
109
111
110
112
With a credential file, you just need to put the file in the right place and the SDK will do the work of parsing and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance.
where `<path>` is something like `/home/user/Downloads/<file_name>.env`.
134
136
137
+
#### Environment Variables
138
+
Simply set the environment variables using <servicename>_<variablename> syntax. For example, using your favourite terminal, you can set environment variables for Assistant service instance:
139
+
140
+
```bash
141
+
export assistant_apikey="<your apikey>"
142
+
export assistant_auth_type="iam"
143
+
```
144
+
145
+
The credentials will be loaded from the environment automatically
146
+
147
+
```python
148
+
assistant = AssistantV1(version='2018-08-01')
149
+
```
150
+
151
+
135
152
#### Manually
136
153
If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of credentials your service instance gives you.
137
154
138
155
### IAM
139
156
140
157
IBM Cloud has migrated to 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.
141
158
142
-
You supply either an IAM service **API key** or an**access token**:
159
+
You supply either an IAM service **API key** or a**bearer token**:
143
160
144
161
- 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.
145
162
- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/services/watson?topic=watson-iam).
146
163
- Use a server-side to generate access tokens using your IAM API key for untrusted environments like client-side scripts. The generated access tokens will be valid for one hour and can be refreshed.
147
164
148
-
###Generating access tokens using IAM API key
165
+
#### Supplying the API key
149
166
```python
150
-
# In your API endpoint use this to generate new access tokens
Version 1.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details.
@@ -225,6 +244,21 @@ The SDK is generated using OpenAPI Specification(OAS3). Changes are basic reorde
225
244
226
245
The package is renamed to ibm_watson. See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details.
227
246
247
+
## Changes for v4.0
248
+
Authenticator variable indicates the type of authentication to be used.
249
+
250
+
```python
251
+
from ibm_watson import AssistantV1
252
+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
253
+
254
+
authenticator = IAMAuthenticator('your apikey')
255
+
assistant = AssistantV1(
256
+
version='2018-07-10',
257
+
## url is optional, and defaults to the URL below. Use the correct URL for your region.
This version includes many breaking changes as a result of standardizing behavior across the new generated services. Full details on migration from previous versions can be found [here](https://github.com/watson-developer-cloud/python-sdk/wiki/Migration).
230
264
@@ -233,12 +267,14 @@ To set client configs like timeout use the `with_http_config()` function and pas
233
267
234
268
```python
235
269
from ibm_watson import AssistantV1
270
+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
236
271
272
+
authenticator = IAMAuthenticator('your apikey')
237
273
assistant = AssistantV1(
238
-
username='xxx',
239
-
password='yyy',
240
-
url='<url_as_per_region>',
241
-
version='2018-07-10')
274
+
version='2018-07-10',
275
+
## url is optional, and defaults to the URL below. Use the correct URL for your region.
If you would like access to some HTTP response information along with the response model, you can set the `set_detailed_response()` to `True`. Since Python SDK `v2.0`, it is set to `True`
279
317
```python
280
318
from ibm_watson import AssistantV1
319
+
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
281
320
321
+
authenticator = IAMAuthenticator('your apikey')
282
322
assistant = AssistantV1(
283
-
username='xxx',
284
-
password='yyy',
285
-
url='<url_as_per_region>',
286
-
version='2018-07-10')
323
+
version='2018-07-10',
324
+
## url is optional, and defaults to the URL below. Use the correct URL for your region.
0 commit comments