我正在开发一个WPF应用程序,要求我使用oAuth从Facebook获取访问令牌.经过大量在线搜索后,我得出以下结论:
我决定创建一个用于进行Facebook身份验证的模态对话框,我可以使用访问令牌而忽略其余部分.我想继续使用MVVM模型,但它比我预期的要困难.任何关于如何做到这一点的想法都会非常有帮助
以下是我实现的一些功能
WPF非常简单.本质上它只是一个WebBrowser控件,其中连接了Navigated和Navigating事件.
<Window x:Class="FacebookAuthenticator.FacebookAuthenticationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Authenticate Facebook"
Height="600"
Width="600"
ResizeMode="NoResize"
WindowStyle="ToolWindow">
<Grid>
<WebBrowser Name="webBrowser"
Navigated="webBrowser_Navigated"
Navigating="webBrowser_Navigating" />
</Grid>
Run Code Online (Sandbox Code Playgroud)
//The Application ID from Facebook
public string AppID {get; set; }
//The access token retrieved from facebook's authentication
public string AccessToken {get; set; }
public FacebookAuthenticationWindow()
{
InitializeComponent();
this.Loaded += (object sender, RoutedEventArgs e) =>
{
//Add the message hook in …Run Code Online (Sandbox Code Playgroud)