【发布时间】:2013-01-22 11:19:35
【问题描述】:
WebAuthenticationBroker 似乎无法处理到我的ms-app:// 的导航。只是抛出这个丑陋的错误,如下所示。
步骤
- 调用
AuthenticateAsync(),包括运行时获取的回调uri:WebAuthenticationBroker.GetCurrentApplicationCallbackUri() - 完成授权过程,点击允许。
- 代理没有返回,而是显示页面无法连接到服务。我们现在无法连接到您需要的服务。 无法执行任何操作,所以我点击了可见的“后退”按钮。
- 调试器在捕获时中断:
"The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)"
接收到WebAuthenticationBroker.AuthenticateAsync() 的回调(根据 Fiddler4 和事件查看器),但它抛出上述异常,好像它不知道如何解释 ms-app:// 协议。
所有示例都表明我的代码应该可以工作,但我认为有一些不太明显的东西会导致问题。
代码
private static string authorizeString =
"https://api.imgur.com/oauth2/authorize?client_id=---------&response_type=token";
private Uri startUri = new Uri(authorizeString);
public async void RequestToken() {
try {
var war = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.UseTitle
, startUri);
// Imgur knows my redirect URI, so I am not passing it through here
if (war.ResponseStatus == WebAuthenticationStatus.Success) {
var token = war.ResponseData;
}
} catch (Exception e) { throw e; }
}
事件查看器日志摘录(按时间顺序)
有关我如何获得此信息的信息,请阅读以下 MSDN:Web authentication problems (Windows)。不幸的是,这是查询 authhost.exe 导航错误时唯一的搜索结果。
-
信息:
AuthHost redirected to URL: <ms-app://s-1-15-2-504558873-2277781482-774653033-676865894-877042302-1411577334-1137525427/#access_token=------&expires_in=3600&token_type=bearer&refresh_token=------&account_username=------> from URL: <https://api.imgur.com/oauth2/authorize?client_id=------&response_type=token> with HttpStatusCode: 302. -
错误:
AuthHost encountered a navigation error at URL: <https://api.imgur.com/oauth2/authorize?client_id=------&response_type=token> with StatusCode: 0x800C000D. -
信息:
AuthHost encountered Meta Tag: mswebdialog-title with content: <Can't connect to the service>.
感谢您的阅读,堆栈。现在不要让我失望!
【问题讨论】:
标签: windows-8 windows-runtime oauth-2.0 imgur