Как пройти аутентификацию с помощью APIKey и URL (https://gateway.watsonplatform.net/natural-language-understanding/api) в .NET SDK Watson (https://github.com/watson-developer-cloud/dotnet-standard-sdk).
) В примере SDK есть SpeechToTextService(username, password);
Но теперь учетные данные Watson имеют только APIKey и URL.
const string SERVICE_NAME = "speech_to_text";
const string URL = "https://stream.watsonplatform.net/speech-to-text/api";
public SpeechToTextService() : base(SERVICE_NAME) { }
public SpeechToTextService(string userName, string password) : base(SERVICE_NAME, URL)
{
if (string.IsNullOrEmpty(userName))
throw new ArgumentNullException(nameof(userName));
if (string.IsNullOrEmpty(password))
throw new ArgumentNullException(nameof(password));
this.SetCredential(userName, password);
}
public SpeechToTextService(TokenOptions options) : base(SERVICE_NAME, URL)
{
if (string.IsNullOrEmpty(options.IamApiKey) && string.IsNullOrEmpty(options.IamAccessToken))
throw new ArgumentNullException(nameof(options.IamAccessToken) + ", " + nameof(options.IamApiKey));
if (!string.IsNullOrEmpty(options.ServiceUrl))
{
this.Endpoint = options.ServiceUrl;
}
else
{
options.ServiceUrl = this.Endpoint;
}
_tokenManager = new TokenManager(options);
}
public SpeechToTextService(IClient httpClient) : base(SERVICE_NAME, URL)
{
if (httpClient == null)
throw new ArgumentNullException(nameof(httpClient));
this.Client = httpClient;
}