Xamarin.Auth Facebook登录完成事件未触发 [英] Xamarin.Auth Facebook login Completed event not firing

查看:50
本文介绍了Xamarin.Auth Facebook登录完成事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Facebook登录按钮创建Xamarin.Forms应用程序.一切工作直到发生 Completed 事件的那一部分,该事件永远不会触发.

I am trying to create a Xamarin.Forms application with a Facebook login button. Everything works up until the part where the Completed event, which never gets fired.

我正在使用 PageRenderer 来启动身份验证流程,如下所示:

I am using a PageRenderer to initiate the auth flow as follows:

[assembly: ExportRenderer(typeof(Page1), typeof(LoginPageRenderer))]
namespace xmrn1.Droid {
    class LoginPageRenderer : PageRenderer {
        private const string ClientId = "<sanitized>";

        public LoginPageRenderer(Context ctx) : base(ctx) { }

        protected override void OnElementChanged(ElementChangedEventArgs<Page> e) {
            base.OnElementChanged(e);

            var authorizeUri = new Uri("https://www.facebook.com/dialog/oauth/");
            var redirectUri = new Uri($"fb{ClientId}://authorize");
            var auth = new OAuth2Authenticator(
                ClientId,
                "email",
                authorizeUri,
                redirectUri);

            auth.Completed += Auth_Completed;
            var ui = auth.GetUI(Context);
            Context.StartActivity(ui);
        }

        private void Auth_Completed(object sender, AuthenticatorCompletedEventArgs e) {
            // This never gets called
        }
    }
}

这是我的"Facebook登录"设置:

And this is my "Facebook Login" settings:

以及我的高级设置"设置:

And my "Advanced Settings" settings:

推荐答案

找到答案了,我不得不在 Facebook Login 设置中打开 Web OAuth Login ,并将 redirectUri 更改为我域中的某些uri,并将该uri添加到同一设置窗口中的 Valid OAuth Redirect URIs 中.

Found the answer, I had to turn on the Web OAuth Login in the Facebook Login settings, and also to change the redirectUri to some uri in my domain, and add that uri to the Valid OAuth Redirect URIs in that same settings window.

奇怪的是,现在,当我登录时,并且出现两因素身份验证代码提示时,我的手机上显示了一个身份验证器弹出通知,要求我批准,并且当我按是"时,它不会自动确认登录后,我还是必须手动输入2fa代码...

Strange thing though, now when I log in, and the two-factor-authentication code prompt shows up, my phone displays an authenticator popup notification asking me to approve and when I press "Yes" it doesn't automatically confirm the login, I have to manually type the 2fa code anyway...

这篇关于Xamarin.Auth Facebook登录完成事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆