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
### Basic Auth (or API key for Visual Recognition)
50
50
You will need the `username`, `password`, and `url` (`api_key` for Visual Recognition) for each service. Service credentials are different from your IBM Cloud account username and password.
51
51
52
52
To get your service credentials, follow these steps:
@@ -59,6 +59,43 @@ To get your service credentials, follow these steps:
59
59
1. Click **View credentials** under **Actions**.
60
60
1. Copy `username`, `password` (or `api_key` for Visual Recognition), and `url`.
61
61
62
+
### IAM
63
+
64
+
When authenticating with IAM, you have the option of passing in:
65
+
- the IAM API key and, optionally, the IAM service URL
66
+
- an IAM access token
67
+
68
+
**Be aware that passing in an access token means that you're assuming responsibility for maintaining that token's lifecycle.** If you instead pass in an IAM API key, the SDK will manage it for you.
69
+
70
+
```js
71
+
// in the constructor, letting the SDK manage the IAM token
72
+
constdiscovery=newDiscoveryV1({
73
+
url:'<service_url>',
74
+
version:'<version-date>',
75
+
iam_apikey:'<iam_api_key>',
76
+
iam_url:'<iam_url>', // optional - the default value is https://iam.ng.bluemix.net/identity/token
77
+
});
78
+
```
79
+
80
+
```js
81
+
// in the constructor, assuming control of managing IAM token
82
+
constdiscovery=newDiscoveryV1({
83
+
url:'<service_url>',
84
+
version:'<version-date>',
85
+
iam_access_token:'<access-token>'
86
+
});
87
+
```
88
+
89
+
```js
90
+
// after instantiation, assuming control of managing IAM token
91
+
constdiscovery=newDiscoveryV1({
92
+
url:'<service_url>',
93
+
version:'<version-date>'
94
+
});
95
+
96
+
discovery.setAccessToken('<access-token>')
97
+
```
98
+
62
99
## Usage
63
100
64
101
The examples below assume that you already have service credentials. If not,
@@ -71,7 +108,9 @@ Credentials are checked for in the following order:
71
108
72
109
1. Hard-coded or programatic credentials passed to the service constructor
73
110
74
-
2.`SERVICE_NAME_USERNAME` and `SERVICE_NAME_PASSWORD` environment properties (or `SERVICE_NAME_API_KEY` when appropriate) and, optionally, `SERVICE_NAME_URL`
111
+
2. Environment variables:
112
+
-`SERVICE_NAME_USERNAME` and `SERVICE_NAME_PASSWORD` environment properties (or `SERVICE_NAME_API_KEY` when appropriate) and, optionally, `SERVICE_NAME_URL`
113
+
- If using IAM: `SERVICE_NAME_IAM_APIKEY` and optionally `SERVICE_NAME_IAM_URL`, or `SERVICE_NAME_IAM_ACCESS_TOKEN`
75
114
76
115
3. IBM-Cloud-supplied credentials (via the `VCAP_SERVICES` JSON-encoded environment property)
0 commit comments