gpt4 book ai didi

c# - 将 WebAuthenticationBroker 用于 oAuth

转载 作者:太空宇宙 更新时间:2023-11-03 11:10:11 25 4
gpt4 key购买 nike

我想将 WebAuthenticationBroker 用于带有 Pocket (http://getpocket.com) 的 oAuth。 Pocket API 在 http://getpocket.com/developer/docs/authentication 中描述。 .问题是重定向 uri。在他们的示例中,它被设置为适用于 iOS 和 Android 的自定义协议(protocol)。你如何在 WinRT 上处理这个问题?

当我提供一个空的重定向 uri 时它不起作用。当我提供类似 http://www.google.sk 的 uri 时,我看到了 pocket 的授权对话框,我授权了我的应用程序,然后我被重定向到 http://www.google.sk .但是窗口不会关闭,我只能单击后退按钮,这会导致 WebAuthenticationResult 被取消。

最佳答案

WebAuthenticationBroker 需要回调 URI。如果在 Web View 中调用此 URI,主机会结束导航并向代理发出信号 - 如 web authentication broker workflow at MSDN 中所述.

您作为 POST 参数提交的 Pocket API redirect_uri 应与 WebAuthenticationBroker.GetCurrentApplicationCallbackUri 相同。

可以指定为第三个参数:

WebAuthenticationBroker.AuthenticateAsync(options, requestUri, callbackUri)

顺便说一句:
如果您需要 Pocket API 的简单包装器,我已经为 C# 构建了一个名为 PocketSharp 的包装器

关于c# - 将 WebAuthenticationBroker 用于 oAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14355195/

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