我有一个Windows 8应用程序,它构建一个字符串并使用WebAuthBroker发布到https:相关代码如下。
问题是WebAuthBroker接受此URI并且无法连接,但是当我将此URI发布到IE中时,它可以正常工作。
在Windows 8上运行VS2012。 在Package.appmanifest中,已启用企业身份验证,Internet(客户端),Internet(客户端和服务器),专用网络(客户端和服务器)和共享用户证书。
async Task AuthenticateAsync()
{
var requestUriStr = string.Format("{0}?client_id={1}&response_type=token&redirect_uri={2}", logonUriString, clientId, redirectUriString);
requestUriStr += "&scope=stream";
var requestUri = new Uri(requestUriStr, UriKind.RelativeOrAbsolute);
var redirectUri = new Uri(redirectUriString, UriKind.RelativeOrAbsolute);
var result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, requestUri, redirectUri);
if (result.ResponseStatus != WebAuthenticationStatus.Success)
{
throw new Exception("Login failed: " + result.ResponseErrorDetail);
}
答案 0 :(得分:3)
我发现了我的问题。来自:http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/13d3742d-4b6b-444e-840e-a4db11462a08
事实证明,如果您使用Fiddler调试您的HTTP请求,它会 使WebAuthenticationBroker停止工作。这可能是也可能不是 与此应用中提供的“解密HTTPS流量”选项相关, 但是当我关闭Fiddler时,WebAuthenticationBroker就开始了 再次工作。我可以通过启动Fiddler来随意复制这个bug 再次,并通过关闭它来解决问题。
我没有进行高级研究,无论是否启用或 禁用Fiddler的HTTPS选项会影响使用 WebAuthenticationBroker类和方法,但初看起来它看起来 像勉强禁用HTTPS将使它再次工作。我通常 亲自关闭,以便更安全。
所以我在写作/调试时一直打开Fiddler。我关闭了Fiddler,它第一次工作了!