UWP app connecting to Azure AD via IdentityModel.OidcClient
generates an error as below.
Exception Message = "The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)" Noting important in Stack Trace!
Exception happens inside public class WabBrowser : IBrowser
's InvokeAsyncCore(BrowserOptions options, bool silentMode)
function.
Code:
public class WabBrowser : IBrowser
{
private readonly bool _enableWindowsAuthentication;
public WabBrowser(bool enableWindowsAuthentication = false)
{
_enableWindowsAuthentication = enableWindowsAuthentication;
}
private async Task<BrowserResult> InvokeAsyncCore(BrowserOptions options, bool silentMode)
{
var wabOptions = WebAuthenticationOptions.UseHttpPost;
if (_enableWindowsAuthentication)
{
wabOptions |= WebAuthenticationOptions.UseCorporateNetwork;
}
if (silentMode)
{
wabOptions |= WebAuthenticationOptions.SilentMode;
}
WebAuthenticationResult wabResult;
try
{
if (string.Equals(options.EndUrl, WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri, StringComparison.Ordinal))
{
wabResult = await WebAuthenticationBroker.AuthenticateAsync(
wabOptions, new Uri(options.StartUrl));
}
else
{
if (string.IsNullOrWhiteSpace(options.EndUrl))
{
wabResult = await WebAuthenticationBroker.AuthenticateAsync(
wabOptions, new Uri(options.StartUrl), WebAuthenticationBroker.GetCurrentApplicationCallbackUri());
}
else
{
wabResult = await WebAuthenticationBroker.AuthenticateAsync(
wabOptions, new Uri(options.StartUrl), new Uri(options.EndUrl));
}
}
}
catch (Exception ex)
{
Utility.WriteErrorsToLogViaMessenger("WabBrowser-InvokeAsyncCore", ex);
return new BrowserResult
{
ResultType = BrowserResultType.UnknownError,
Error = ex.ToString()
};
}
}
This issue occurs only connecting to Azure AD
and when connecting to other Identity servers this implementation works fine.
Any help would be appreciated.