c# - 使用 WebAuthenticationBroker 进行 oAuth

标签 c# windows-8 oauth microsoft-metro

我想通过 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/

相关文章:

php - 将多个 oauth 帐户链接到单个用户 : what's considered safe practice and what's not?

oauth - nginx 负载均衡器和 OAuth

javascript - Firebase JS v9 中 Google Auth Provider 的 select_account 提示

c# - 设置单用户模式恢复备份

c# - Windows 手机 7 - 仅限 C#?

windows-8 - 获取正在运行的 MetroStyle 应用程序列表

windows-8 - 在 Windows 8/Server 2012 中 deDE 中 NaN 的本地化返回 "NaN"而不是 "n. def."

c# - 标准方法与扩展方法

c# - App_Data没有访问权限

javascript - 使用 Windows Live SDK 的 Windows 8 Metro 应用单点登录