I have a C# application that connects to a web-service API. We have been using Basic Authentication to connect and that works OK. Now in an environment with SSO, it fails to connect and returns an "UnAuthorized" error when attempting to connect to access the web service URL.
The connection happens in a library that we are using. I can see that the library uses HttpWebRequest and has code like the following:
HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);
conn.Method = method;
resource.StartResource(conn);
...
string userAgent = session.GetValue(SessionParameter.UserAgent) as String;
conn.UserAgent = userAgent == null ? "API Client" : userAgent;
...
if (user != null || password != null)
{
conn.Credentials = new NetworkCredential(user ?? string.Empty, password ?? string.Empty);
}
...
conn.PreAuthenticate = true;
...
conn.CookieContainer = Cookies;
...
HttpWebResponse response = (HttpWebResponse)conn.GetResponse();
What do I need to do differently in the case when SSO is used?