Hi All,
I would like to pass my Windows credentials from a simple http client for Netduino plus 2
this is the approach I am taking but I haven't being successful so far..
NetworkCredentials class I understand does not support NTLM and I cannot use CredentialCache in the .net micro framework
Should I inject the credentials in the header? if yes how?
Thanks in advance
var sample = "test this";
byte[] buffer = Encoding.UTF8.GetBytes(sample);
// produce request
var requestUri = @http://SomeWhereThat...hentication.com;
using (var request = (HttpWebRequest)WebRequest.Create(requestUri))
{
request.Method = "POST";
string username = @"myusername";
string password = "mypwd";
NetworkCredential myCred = new NetworkCredential(username, password);
// headers
request.ContentType = "application/json";
request.ContentLength = buffer.Length;
//request.Headers.Add("Authorization", "NTLM " + authInfo); is this a good lead?!?!?
request.Credentials = myCred;
request.Credentials.AuthenticationType = AuthenticationType.Basic;
request.KeepAlive = false;
// content
Stream s = request.GetRequestStream();
s.Write(buffer, 0, buffer.Length);
// send request and receive response
using (var response = (HttpWebResponse)request.GetResponse())
{
// consume response
Debug.Print("sample: " + sample);
Debug.Print("request uri: " + requestUri);
Debug.Print("Status code: " + response.StatusCode);
}
}