我想通过 Pocket (http://getpocket.com) 使用 WebAuthenticationBroker 进行 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/