I'm trying to login to this website https://idp.bexio.com/login using http webrequest. This is my current code. I've done alot of research but none of it seems to fit these needs.
CookieContainer cc = new CookieContainer();
Uri uri = new Uri("https://office.bexio.com/oauth/authorize?client_id=Client_ID&redirect_uri=https://office.bexio.com&state=STATE&scope=SCOPE&response_type=code");
string data = "login-form.j_username=xxxxx&login-form.j_password=xxxxx";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.CookieContainer = cc;
request.Method = WebRequestMethods.Http.Post;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tmp = reader.ReadToEnd();
response.Close();
Console.WriteLine(tmp);
The resposne I'm getting is just the login page, and not the logged in page as I want. Any help is appreciated.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire