Sample code for 30+ languages & platforms
.NET Core C#

HTTP Basic Authentication

Demonstrates how to use HTTP Basic authentication.

Chilkat .NET Core C# Downloads

.NET Core C#
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Http http = new Chilkat.Http();

// To use HTTP Basic authentication:
http.Login = "myLogin";
http.Password = "myPassword";
http.BasicAuth = true;

// Run the test using this URL with the credentials above.  
// (Works while httpbin.org keeps the test endpoint available.)
string jsonResponse = http.QuickGetStr("https://httpbin.org/basic-auth/myLogin/myPassword");
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Debug.WriteLine("Response status code: " + Convert.ToString(http.LastStatus));

Debug.WriteLine(jsonResponse);

// Output:

// Response status code: 200
// {
//   "authenticated": true, 
//   "user": "myLogin"
// }