gpt4 book ai didi

windows-8 - WebAuthenticationBroker 收到 OAuth2 回调时抛出异常

转载 作者:行者123 更新时间:2023-12-03 20:37:46 32 4
gpt4 key购买 nike

WebAuthenticationBroker 似乎无法处理到我的 ms-app:// 的导航。 .只是抛出这个丑陋的错误,如下所示。

脚步

  • 调用 AuthenticateAsync() ,包括运行时获取的回调uri:WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
  • 完成授权流程,点击允许 .
  • 经纪人没有返回,而是显示页面无法连接到服务。我们现在无法连接到您需要的服务。 什么都做不了,所以我点击了可见的后退按钮。
  • 调试器在捕获时中断:"The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)"
  • WebAuthenticationBroker.AuthenticateAsync() 的回调已收到(根据 Fiddler4 和事件查看器),但它抛出上述异常,好像它不知道如何解释 ms-app://协议(protocol)。

    所有示例都暗示我的代码应该可以工作,但我认为有一些不太明显的东西会导致问题。

    代码
    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>.

  • 感谢阅读,堆栈。现在不要让我失望!

    最佳答案

    Afaik,即使您假设远程服务知道它,您也需要将结束 URL 传递给 AuthenticateAsync。

    WebAuthenticationBroker 的工作方式如下:您指定一个“端点” URL,当它遇到以该 URL 开头的链接时,它会认为身份验证过程已完成,甚至不再尝试导航到该 URL。
    因此,如果您将“foo://bar”指定为回调 URI,导航到“foo://bar”将完成身份验证,“foo://barbaz”也会完成身份验证,但不会“foo://baz”。

    关于windows-8 - WebAuthenticationBroker 收到 OAuth2 回调时抛出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14742974/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com