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
Copy file name to clipboardExpand all lines: README.md
+70-18Lines changed: 70 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,76 @@ You can get the latest SDK packages through NuGet. Installation instructions can
39
39
40
40
Or manually [here][latest_release].
41
41
42
+
## Authentication
43
+
Watson services are migrating to token-based Identity and Access Management (IAM) authentication.
44
+
45
+
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
46
+
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
47
+
- Visual Recognition uses a form of [API key](#api-key) only with instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
48
+
49
+
### Getting credentials
50
+
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:
51
+
52
+
1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page.
53
+
1. Either click an existing Watson service instance or click **Create**.
54
+
1. Click **Show** to view your service credentials.
55
+
1. Copy the `url` and either `apikey` or `username` and `password`.
56
+
57
+
In your code, you can use these values in the service constructor or with a method call after instantiating your service.
58
+
59
+
### IAM
60
+
61
+
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.
62
+
63
+
You supply either an IAM service **API key** or an **access token**:
64
+
65
+
- 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.
66
+
- Use the access token if you want to manage the lifecycle yourself. Access tokens are valid. 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.
**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam).
You can send custom request headers by adding them to the `customData` object.
44
114
```cs
@@ -72,24 +142,6 @@ void Example()
72
142
}
73
143
```
74
144
75
-
## IAM Authentication
76
-
You can authenticate using IAM rather than username and password or apikey. You can either allow the SDK to manage the token by providing your IAM apikey or manage the token yourself by providing an access token.
77
-
```cs
78
-
voidExample()
79
-
{
80
-
// Provide either an iamApiKey or iamAccessToken to authenticate the service.
0 commit comments