Skip to content

Commit a3fb341

Browse files
authored
Merge branch 'development' into 4609-iam-url
2 parents de394d0 + 5ea7a4f commit a3fb341

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,7 @@ _Pvt_Extensions
239239
.fake/
240240
/src/IBM.WatsonDeveloperCloud.LanguageTranslator.Test/appsettings.json
241241
/test/IBM.WatsonDeveloperCloud.LanguageTranslator.v2.IntegrationTests/appsettings.json
242+
243+
**/.swagger-codegen-ignore
244+
**/.swagger-codegen
245+
src/tests/

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ void Example()
7272
```
7373

7474
## IAM Authentication
75-
You can authenticate using IAM rather than username and password. 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.
75+
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.
7676
```cs
7777
void Example()
7878
{
7979
// Provide either an iamApiKey or iamAccessToken to authenticate the service.
8080
TokenOptions iamAssistantTokenOptions = new TokenOptions()
8181
{
8282
IamApiKey = "<iam-apikey>",
83-
IamAccessToken = "<iam-access-token>"
83+
IamAccessToken = "<iam-access-token>",
84+
IamUrl = "<service-endpoint>"
8485
};
8586

8687
_assistant = new AssistantService(iamAssistantTokenOptions, "<version-date>");

src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ PM > Install-Package IBM.WatsonDeveloperCloud.VisualRecognition.v3
1818
</ItemGroup>
1919

2020
```
21+
2122
### Usage
2223
The IBM Watson™ [Visual Recognition][visual-recognition] service uses deep learning algorithms to identify scenes, objects, and faces in images you upload to the service. You can create and train a custom classifier to identify subjects that suit your needs. You can create and add images to a collection and then search that collection with your own image to find similar images. A valid API Key from IBM Cloud is required for all calls.
2324

2425
#### Instantiating and authenticating the service
25-
Before you can send requests to the service it must be instantiated and api key must be set.
26+
Before you can send requests to the service it must be instantiated and api key or access token must be set.
2627
```cs
27-
// create a Tone Analyzer Service instance
28-
VisualRecognitionService _visualRecognition = new VisualRecognitionService();
29-
30-
// set the credentials
31-
_visualRecognition.SetCredential("<apikey>");
28+
TokenOptions tokenOptions = new TokenOptions()
29+
{
30+
IamApiKey = "<iam-apikey>",
31+
IamAccessToken = "<iam-access-token>",
32+
IamUrl = "<service-endpoint>"
33+
};
3234

33-
// set the VersionDate
34-
_visualRecognition.VersionDate = "version-date";
35+
var _visualRecognition = new VisualRecognitionService(tokenOptions, "<version-date>");
3536
```
3637

3738
#### Classify an image

src/IBM.WatsonDeveloperCloud.VisualRecognition.v3/VisualRecognitionService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public partial class VisualRecognitionService : WatsonService, IVisualRecognitio
3232
{
3333
const string SERVICE_NAME = "visual_recognition";
3434
const string URL = "https://gateway.watsonplatform.net/visual-recognition/api";
35-
private TokenManager _tokenManager = null;
3635
private string _versionDate;
3736
public string VersionDate
3837
{

src/IBM.WatsonDeveloperCloud/Service/WatsonService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
using System;
1919
using IBM.WatsonDeveloperCloud.Http;
20+
using IBM.WatsonDeveloperCloud.Util;
2021

2122
namespace IBM.WatsonDeveloperCloud.Service
2223
{
@@ -43,6 +44,7 @@ public string Endpoint { get
4344
}
4445
public string UserName { get; set; }
4546
public string Password { get; set; }
47+
protected TokenManager _tokenManager = null;
4648

4749
protected WatsonService(string serviceName)
4850
{
@@ -88,6 +90,13 @@ public void SetCredential(string userName, string password)
8890
public void SetCredential(string apikey)
8991
{
9092
this.ApiKey = apikey;
93+
this.Endpoint = "https://gateway-a.watsonplatform.net/visual-recognition/api";
94+
}
95+
96+
public void SetCredential(TokenOptions options)
97+
{
98+
this.Endpoint = options.IamUrl;
99+
_tokenManager = new TokenManager(options);
91100
}
92101
}
93102
}

0 commit comments

Comments
 (0)