xamarin - 身份验证错误 e.Message = OAuth 错误 = 权限+错误

标签 xamarin xamarin.ios xamarin.android facebook-authentication xamarin.auth

我在我的 xamarin.android 和 xamarin.ios (PCL) 项目中使用 Xamarin.Auth 版本 1.5.0.3,通过 facebook 的 OAuth API 进行应用程序身份验证/登录。我单击“现在不”链接后出现问题(请观看下面的屏幕截图)。我收到以下错误对话框:

Authentication Error e.Message = OAuth Error = Permissions+error

有什么方法可以禁用此链接或以某种方式修复它吗?或者有人知道为什么会发生这种情况吗?

enter image description here

enter image description here

iOS 代码(现在可以运行):

public override void ViewDidAppear(bool animated)
{
    base.ViewDidAppear(animated);

    var auth = new OAuth2Authenticator(
        clientId: "myClientId",
        scope: "",
        authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),
        redirectUrl: new Uri("https://www.facebook.com/connect/login_success.html"),
        isUsingNativeUI: true
    );

    auth.Completed += (sender, eventArgs) =>
    {
        if (eventArgs.IsAuthenticated)
        {

        }
        else
        {

        }
    };

    var errorWasAlreadyTrown = false;
    auth.Error += (object sender, AuthenticatorErrorEventArgs eventArgs) =>
        {
                if (!errorWasAlreadyTrown)
                {
                    OAuth2Authenticator auth2 = (OAuth2Authenticator)sender;
                    auth2.ShowErrors = false;

                    App.SuccessfulLoginAction.Invoke();
                    errorWasAlreadyTrown = true;
                }
        };

    PresentViewController(auth.GetUI(), true, null);
}

但它仍然无法在 Android 上运行。所有代码都是相同的,除了在 iOS 上我重写了“ViewDidAppear”方法,在 Android 上重写了“OnElementChanged”方法。最后,我在 iOS 上调用“PresentViewController”,在 Android 上调用“activity.StartActivity”。

我按照此处的一些说明进行操作:How to login to facebook in Xamarin.Forms

最佳答案

当点击“现在不”链接时,有隐藏对话框的方法,并出现错误:

auth.Error += (sender, eventArgs) =>
{
  OAuth2Authenticator auth2 = (OAuth2Authenticator)sender;
  auth2.ShowErrors = false;
  auth2.OnCancelled();
};

关于xamarin - 身份验证错误 e.Message = OAuth 错误 = 权限+错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45237177/

相关文章:

android - 内部/SD 卡的 Environment.ExternalStorageDirectory

xamarin.forms - Xamarin Forms Android 中步进器宽度无法正确调整大小

xamarin - Xamarin 中的 Gradle 依赖项

c# - 在 Xamarin 平台上从 C# 引用本地资源

c# - 在 Xamarin Forms 的 Master/Detail 布局中从当前页面切换时保留 WebView 的加载页面内容

encryption - 使用 Xamarin 保护跨平台存储选项

attributes - 单点触控 : Understand Foundation Attributes

ios - 是否可以在测试的iPhone上安装我的App

c# - 无法加载文件或程序集 'System.Private.CoreLib...'

xamarin.ios - Xamarin zxing 不要求在 IOS 上允许摄像头