Friday, October 21, 2016

HTTP Basic Authentication/Authorization

Basic Authorization is simpliest and easier way to make your service secure if it is using HTTPS (HTTP over SSL)

Usage example:
var client = new WebClient {Credentials = new NetworkCredential("user_name", "password")};
var response = client.DownloadString("https://someserver.com/blabla/blabla");
One more:

string username = "Your username";
string password = "Your password";

string svcCredentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));

request.Headers.Add("Authorization", "Basic " + svcCredentials);

An Encoding Parameter for HTTP Basic Authentication Description:
http://greenbytes.de/tech/webdav/draft-reschke-basicauth-enc-latest.html

No comments: