Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>WOW WHAT A PAIN!</h1> <p>I have no idea why this took me so long to figure out, but after hours and hours and DAYs, of trying to get this stupid auth to work I finally figured it out. Here is the code. </p> <p>One weird thing is I had to create the header format for the cookie. Which by definition isn't a true cookie, it is a damn header value. I had to create the header title, because when I extracted the JSON object from the file and converted it to string I was unable to keep the format in tact from the file.</p> <pre><code>public HttpWebResponse InitiliazeWebRequest() { string responseData = string.Empty; string loginInstance = "url + logincreds"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(loginInstance); request.Method = "POST"; request.ContentType = "application/json"; request.CookieContainer = new CookieContainer(); HttpWebResponse response = (HttpWebResponse)request.GetResponseAsync().Result; if (response.StatusCode == HttpStatusCode.OK) { using (System.IO.StreamReader responseReader = new System.IO.StreamReader(request.GetResponse().GetResponseStream())) { responseData = responseReader.ReadToEnd(); } var toke = response.Headers.Get("authToken"); JObject o = JObject.Parse(responseData); _authToken = (string)o["response"]["authToken"].ToString(); return response; } return response; } public HttpWebResponse LogOut() { string responseData = string.Empty; string loginInstance = "https://www.example.com/logout"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(loginInstance); request.Method = "GET"; request.ContentType = "application/json"; request.Headers.Add("Cookie: authToken=" + _authToken); HttpWebResponse response = (HttpWebResponse)request.GetResponseAsync().Result; if (response.StatusCode == HttpStatusCode.OK) { using (System.IO.StreamReader responseReader = new System.IO.StreamReader(request.GetResponse().GetResponseStream())) { responseData = responseReader.ReadToEnd(); } return response; } return response; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload