I have a UWP app that signs in using Azure AD. I deployed it to a customer site and it stopped logging in. They have a network with a proxy and I don't have access to their network, so I can't debug it properly. All the information I was provided is:
There's a proxy, you might want to use the default proxy settings. The proxy requires default windows authentication.
So with that information, here's what I've tried:
- Update my
PublicApplicationBuilderto use a customHttpClientFactory
this.publicClientApp = PublicClientApplicationBuilder.Create(ClientId)
.WithAuthority(Authority)
.WithHttpClientFactory(new MsalHttpClientFactory())
.OtherNonRelevantMethods()
.Build();
- I created a custom implementation of
IMsalHttpClientFactorywhich attempts to set the proxy. There's a function,GetHttpClientwhich should setup (as the name says) anHttpClientobject with all the necesary configuration
private HttpClient GetHttpClient()
{
var handler = new HttpClientHandler();
handler.UseProxy = true;
handler.UseDefaultCredentials = true;
return new HttpClient(handler);
}
This doesn't seem to work. It was my first attempt at using both the default proxy and default windows credentials.
I have also tried to manually set the proxy credentials with the following code
private HttpClient GetHttpClient()
{
var handler = new HttpClientHandler();
handler.UseProxy = true;
handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials
return new HttpClient(handler);
}
But it seems to do the same thing, and therefore doesn't work.
And finally I tried to manually retrieve the proxy from WebRequest and Credentials from CredentialCache but again... no luck.
private HttpClient GetHttpClient()
{
var handler = new HttpClientHandler();
handler.UseProxy = true;
handler.Proxy = WebRequest.DefaultWebProxy;
handler.Proxy.Credentials = CredentialCache.DefaultCredentials;
return new HttpClient(handler);
}
I'm unfortunately running out of ideas, I have been able to make this work by running it through Telerik Fiddler, so obviously Fiddler can reach the proxy just fine and when Fiddler operates as a man in the middle, my application works fine. But I can't simply ask them to run fiddler every time haha
Do you have any ideas? Am I missing something super easy?
Thanks