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
The SDK will search for this file in the following order
191
-
- Path specified by environmental variable `IBM_CREDENTIALS_FILE`
192
-
- System home directory
193
-
- Top level of the project directory
182
+
### Supplying credentials
183
+
184
+
There are two ways to supply the credentials you found above to the SDK for authentication.
185
+
186
+
#### Credential file (easier!)
187
+
188
+
With a credential 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.
189
+
190
+
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):
191
+
192
+
- Your system's home directory
193
+
- The top-level directory of the project you're using the SDK in
194
+
195
+
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:
194
196
195
-
Using a `ibm-credentials.env` file you can easily instantiate and authenticate a service. If you are using an IAM Apikey you will need to invoke this using a coroutine to wait for the authorization token.
196
197
```cs
197
198
publicIEnumeratorExampleAutoService()
198
199
{
@@ -205,7 +206,23 @@ public IEnumerator ExampleAutoService()
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.
214
+
215
+
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:
216
+
217
+
```bash
218
+
export IBM_CREDENTIALS_FILE="<path>"
219
+
```
220
+
221
+
where `<path>` is something like `/home/user/Downloads/<file_name>.env`.
222
+
223
+
#### Manually
224
+
225
+
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.
209
226
210
227
## Callbacks
211
228
Success and failure callbacks are required. You can specify the return type in the callback.
0 commit comments