In my angular controller, I have the following code to check if logon is required:
$scope.checkApi = "api/check";
$http.post($scope.checkApi).then(function (response)
{
if (response.status != 200)
{
alert("Logon required.");
}
}, function (response)
{
if (response.status != 200)
{
alert("Logon required.");
}
});
If logon is required, then from the controller I want to display the logon page to get user name and password, then use the user name and password to access the web API like this:
var userCredential = btoa(userName + ":" + password");
$http.get(usersApi, { headers: { "Authorization": "Basic " + userCredential } }).then(function (response)
{
});
Thanks.