How to preserve Basic Auth after redirecting in HttpClient?
- Original URL: https://myapp.herokuapp.com/api/login
- Redirect URL with custom domain: http://io.myapp.co/api/login
Below is my code I use in Xamarin Forms. When I use the original URL, authentication works. But when I use the redirect URL, I get an "Unauthorized" response. The redirect URL works fine in Postman.
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("email", TxtEmail.Text);
client.DefaultRequestHeaders.Add("password", TxtPassword.Text);
client.DefaultRequestHeaders.Authorization = HttpClientHelper.NdAuth;
var result = await client.GetAsync(Constants.UrlLoginUser);
}
How to preserve Basic Auth while redirecting? How Postman is able to do it?