string apiUrl = "http://40.87.141.219:1880/ui/"; // API endpoint
using (HttpClient httpClient = new HttpClient())
{
string base64Credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64Credentials);
HttpResponseMessage responsec = await httpClient.GetAsync(apiUrl);
await Console.Out.WriteLineAsync("");
try
{
HttpResponseMessage response = await httpClient.GetAsync(apiUrl);
if (response.IsSuccessStatusCode)
{
Device.BeginInvokeOnMainThread(async () =>
{
string content = await response.Content.ReadAsStringAsync();
// Create a new WebView to display the downloaded content
WebView webView = new WebView
{
Source = new HtmlWebViewSource { Html = content },
VerticalOptions = LayoutOptions.FillAndExpand
};
// Replace the existing content of the page with the WebView
Content = webView;
await Task.Delay( 5000);
webView.Reload();
});
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
kosulum = false;
await DisplayAlert("Login notttt", "AR" + kosulum, "AR");
}
}
catch (HttpRequestException e)
{
Console.WriteLine($"HTTP Request Error: {e.Message}");
kosulum = false;
}
}
i try to login with http basic auth , it approves login but
shows somethng like that?
anyone work with that before?