I have a script dat i want to convert to modern authentication. I cant find the right properties to do it. Could you help me?
HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default);
HttpWebRequest.DefaultCachePolicy = policy;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.CachePolicy = noCachePolicy;
request.Method = "GET";
string encoded = "username:password";
request.Headers.Add("Authorization", "Basic " + encoded);
request.ContentType = "application/xml";
request.Headers["x-api-key"] = "12312312-1234-1234-1234-123123123123";
ServicePointManager.ServerCertificateValidationCallback = delegate (
Object obj, X509Certificate certificate, X509Chain chain,
SslPolicyErrors errors)
{
return (true);
};
HttpWebResponse response;
try
{
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
string responseStr = new StreamReader(responseStream).ReadToEnd();
Console.WriteLine(responseStr);
return responseStr;
}
}
catch (Exception e)
{
Task.Run(() =>
{
});
}
I probaly need something like ConfidentialClientApplicationBuilder but i cant seem to find how to do it.