/// <summary> /// All the admin related tasks are not available via just an API key and user, this mimicks logging in a normal user /// If the user is admin, admin methods are available. /// </summary> /// <param name="userName"></param> /// <param name="pass"></param> public void Login(string userName, string pass) { //client.Post <LoginAuthResponse>("/session", new LoginAuth { username = userName, password = pass }); var csrfWebresponse = client.Get <GetCsrfTokenResponse>(new GetCsrfToken()); client.Headers.Add("X-CSRF-Token", csrfWebresponse.csrf); csrf = csrfWebresponse.csrf; client.Headers.Add("X-Request-With", "XMLHttpRequest"); client.SetCredentials(userName, pass); client.GetUrl("/session").PostToUrl(new LoginAuth { username = userName, password = pass }, "*/*", webReq => { webReq.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; webReq.Headers.Add("X-CSRF-Token", csrfWebresponse.csrf); webReq.Headers.Add("X-Request-With", "XMLHttpRequest"); webReq.CookieContainer = client.CookieContainer; }, webRes => { client.CookieContainer.Add(webRes.Cookies); }); }