Skip to content

Commit 5c95f52

Browse files
authored
docs: update proxy docs to include iam auth usage (#1023)
explaining that authenticators that makes network requests also need the proxy configured
1 parent a5a8d05 commit 5c95f52

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,21 +325,29 @@ const myInstance = new watson.WhateverServiceV1({
325325
The SDK provides the user with full control over the HTTPS Agent used to make requests. This is available for both the service client and the authenticators that make network requests (e.g. `IamAuthenticator`). Outlined below are a couple of different scenarios where this capability is needed. Note that this functionality is for Node environments only - these configurtions will have no effect in the browser.
326326

327327
### Use behind a corporate proxy
328-
To use the SDK (which makes HTTPS requests) behind an HTTP proxy, a special tunneling agent must be used. Use the package [`tunnel`](https://github.com/koichik/node-tunnel/) for this. Configure this agent with your proxy information, and pass it in as the HTTPS agent in the service constructor. Additionally, you must set `proxy` to `false` in the service constructor. See this example configuration:
328+
To use the SDK (which makes HTTPS requests) behind an HTTP proxy, a special tunneling agent must be used. Use the package [`tunnel`](https://github.com/koichik/node-tunnel/) for this. Configure this agent with your proxy information, and pass it in as the HTTPS agent in the service constructor. Additionally, you must set `proxy` to `false` in the service constructor. If using an Authenticator that makes network requests (IAM or CP4D), you must set these fields in the Authenticator constructor as well.
329+
330+
See this example configuration:
329331
```js
330332
const tunnel = require('tunnel');
331333
const AssistantV1 = require('ibm-watson/assistant/v1');
332334
const { IamAuthenticator } = require('ibm-watson/auth');
333335

336+
const httpsAgent = tunnel.httpsOverHttp({
337+
proxy: {
338+
host: 'some.host.org',
339+
port: 1234,
340+
},
341+
});
342+
334343
const assistant = new AssistantV1({
335-
authenticator: new IamAuthenticator({ apikey: 'fakekey-1234' }),
336-
version: '2019-02-28',
337-
httpsAgent: tunnel.httpsOverHttp({
338-
proxy: {
339-
host: 'some.host.org',
340-
port: 1234,
341-
},
344+
authenticator: new IamAuthenticator({
345+
apikey: 'fakekey-1234'
346+
httpsAgent, // not necessary if using Basic or BearerToken authentication
347+
proxy: false,
342348
}),
349+
version: '2020-01-28',
350+
httpsAgent,
343351
proxy: false,
344352
});
345353
```

0 commit comments

Comments
 (0)