Visual studio 如何使用Xamarin Auth对facebook用户进行身份验证?

Visual studio 如何使用Xamarin Auth对facebook用户进行身份验证?,visual-studio,authentication,xamarin.forms,xamarin.android,xamarin.auth,Visual Studio,Authentication,Xamarin.forms,Xamarin.android,Xamarin.auth,我正在开发一个通过xamarin auth验证facebook用户名的应用程序,这意味着用户不需要登录,但他们可以验证他们的用户电子邮件。下面是我的用户界面设计代码: Login.xaml <?xml version="1.0" encoding="utf-8" ?> <ContentPage BackgroundColor="Blue" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http:/

我正在开发一个通过xamarin auth验证facebook用户名的应用程序,这意味着用户不需要登录,但他们可以验证他们的用户电子邮件。下面是我的用户界面设计代码:

Login.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage BackgroundColor="Blue" xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Test1.Login"

         Padding="10,20,0,0">
<StackLayout VerticalOptions="Center" Spacing="20">
    <Label Text="Login ID" TextColor="Black" FontSize="Large"/>
    <Entry x:Name="Username"  Keyboard="Default" Placeholder="sample@hotmail.com" TextColor="AntiqueWhite"/>
    <Label Text="Password" TextColor="AntiqueWhite" FontSize="Large"/>
    <Entry IsPassword="True" TextColor="AntiqueWhite"/>
    <Label x:Name="label"/>
    <Button Text="Sign In" Clicked="Button_Clicked"/>
</StackLayout>

我已经设置了验证器功能,但无法验证facebook用户电子邮件,以下是我的代码:

Login.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Xamarin.Auth;
using UIKit;
namespace Test1
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Login : ContentPage
    {
        static NavigationPage _NavPage;
        static string _Token;
        public static string Token
        {
            get
            {
                return _Token;
            }
        }
        public static void SaveToken(string token)
        {
            _Token = token;
        }
        public static Action SuccessfulLoginAction
        {
            get
            {
                return new Action(() =>
                {
                    _NavPage.Navigation.PopModalAsync();
                });
            }
        }
        public void Button_Clicked(object sender, EventArgs e)
        {

            var username = Username.Text;
            var emailpattern =
            "^(?(\".+?(?<!\\\\)\"@)|(([0-9a-z]((\\.(?!\\.))|[-!#\\$%&\'\\*\\+/=\\?\\^'\\{\\}\\|~\\w])*)(?<=[0-9a-z])@))(?(\\[)(\\[(\\d{1,3}\\.){3}\\d{1,3}\\])|(([0-9a-z][-\\w]*[0-9a-z]*\\.)+[a-z0-9][\\-a-z0-9]{0,22}[a-z0-9]))$";
            if (Regex.IsMatch(username, emailpattern))
            {
                var auth = new OAuth2Authenticator(
                clientId: "371xxxxxxxxx",
                scope: "",
                authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),
                redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html")
                );

                auth.Completed += (Sender, EventArgs) =>
                {
                    if (EventArgs.IsAuthenticated)
                    {
                        Login.SuccessfulLoginAction.Invoke();
                        Login.SaveToken(EventArgs.Account.Properties["EAxxxxxxxxxxxxx"]);
                    } else { }
                };

                label.Text = "Email is valid";
            }
            else
            {
                label.Text = "Email is not valid";
            };
        }
        public Login()
        {
            InitializeComponent();
        }

    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Text.RegularExpressions;
使用Xamarin.Forms;
使用Xamarin.Forms.Xaml;
使用Xamarin.Auth;
使用UIKit;
名称空间Test1
{
[XamlCompilation(XamlCompilationOptions.Compile)]
公共部分类登录:ContentPage
{
静态导航页面_导航页面;
静态字符串\u标记;
公共静态字符串令牌
{
得到
{
返回令牌;
}
}
公共静态void保存令牌(字符串令牌)
{
_令牌=令牌;
}
公共静态动作成功
{
得到
{
返回新操作(()=>
{
_NavPage.Navigation.PopModalAsync();
});
}
}
已单击公共无效按钮(对象发送者,事件参数e)
{
var username=username.Text;
var模式=
"^(?(\".+?(?