Login with Basic Authentication in web api
<p>I'm using In-Build template for Login and Registration in Web Api. </p>

<p>It uses Token based Authentication . </p>

<p>But what I want is to login a user I want use Basic authentication, after web api will return a token then now I want to use that to to call api methods.</p>

<p>right now I request for login like this</p>

<pre><code>var resp = $http({
            url: "/TOKEN",
            method: "POST",
            data: $.param({ grant_type: 'password', username: userlogin.username, password: userlogin.password }),
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
        });
</code></pre>

<p>and It return me a token, which I send it with next request to call authorize methods.</p>

<p>But I wand to send username and password <strong>:</strong> separated like basic authentication</p>

<pre><code>HttpClient client = new HttpClient();

 string authInfo = "admin" + ":" + "123456";
 authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
 client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo);

 client.BaseAddress = new Uri("http://localhost:63173/TOKEN");
</code></pre>

<p>And server side I will decode it back to get username and password to validate user and will return authentication token.</p>

<pre><code>var encoding = Encoding.GetEncoding("iso-8859-1");
                credentials = encoding.GetString(Convert.FromBase64String(credentials));

                int separator = credentials.IndexOf(':');
                string name = credentials.Substring(0, separator);
                string password = credentials.Substring(separator + 1);
</code></pre>

<p>But I don't know where to modify the existing code. </p>