public void Authenticate(string UserName, string Password) { TextReader tw = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("{0}/@api/deki/users/authenticate", Address)); request.Credentials = new NetworkCredential(UserName, Password); request.Method = "GET"; // Now get the response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); tw = new StreamReader(response.GetResponseStream()); // Read auth token this.authToken = tw.ReadToEnd(); state = DekiCommState.Authenticated; } catch (WebException e) { if (e.Status == WebExceptionStatus.TrustFailure) { state = DekiCommState.TrustFailure; } } catch (Exception e) { throw new Exception("Authentication has failed", e); } finally { if (tw != null) { tw.Close(); } } }
public void Authenticate(string UserName, string Password) { TextReader tw = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format("{0}/@api/deki/users/authenticate", Address)); request.Credentials = new NetworkCredential(UserName, Password); request.Method = "GET"; // Now get the response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); tw = new StreamReader(response.GetResponseStream()); // Read auth token this.authToken = tw.ReadToEnd(); state = DekiCommState.Authenticated; } catch (WebException e) { if (e.Status == WebExceptionStatus.TrustFailure) state = DekiCommState.TrustFailure; } catch (Exception e) { throw new Exception("Authentication has failed", e); } finally { if (tw != null) tw.Close(); } }