使用facebook验证Xamarin.Auth会导致状态显式流

使用facebook验证Xamarin.Auth会导致状态显式流,facebook,authentication,xamarin,xamarin.forms,Facebook,Authentication,Xamarin,Xamarin.forms,我正在使用Xamarin.Auth组件实现facebook登录。我请求我的后端aspnet webapi登录,它返回一个质询结果,我的应用程序将重定向到facebook登录。在重定向的同时,我也在应用程序中得到一个弹出窗口,说服务器的状态无效。可能是伪造的!在来源中找到的 如果我调查请求,我可以看到OAuth2Authenticator类中生成了一个状态 我的问题是,在当前设置中处理身份验证的最佳方式是,还是应该避免让自己的后端重定向应用程序登录。相反,让应用程序直接登录facebook,并将令

我正在使用Xamarin.Auth组件实现facebook登录。我请求我的后端aspnet webapi登录,它返回一个质询结果,我的应用程序将重定向到facebook登录。在重定向的同时,我也在应用程序中得到一个弹出窗口,说服务器的状态无效。可能是伪造的!在来源中找到的

如果我调查请求,我可以看到OAuth2Authenticator类中生成了一个状态

我的问题是,在当前设置中处理身份验证的最佳方式是,还是应该避免让自己的后端重定向应用程序登录。相反,让应用程序直接登录facebook,并将令牌从facebook发送到我的后端,在那里我将通过调用验证它,然后生成我自己的auth_令牌(如果调用有效)

我刚读了Instagram的登录文档

这正是我的意思,隐式或显式流。对我来说,由于国家的原因,Explicit没有与Xamarin.Auth合作对抗facebook


致以最诚挚的问候

关于这一点,游戏在这里进行得有点晚了,但我最近遇到了同样的问题,我正在尝试连接一个ASP.NET web API

我最终做的是扩展OAuth2Authenticator类并重写OnPageConference。有关Xamarin.Android的实现,请参见以下内容:

public class DroidOAuth2Authenticator : OAuth2Authenticator
{
    ...

    protected override void OnPageEncountered(Uri url, System.Collections.Generic.IDictionary<string, string> query, System.Collections.Generic.IDictionary<string, string> fragment)
    {
        // Remove state from dictionaries. 
        // We are ignoring request state forgery status 
        // as we're hitting an ASP.NET service which forwards 
        // to a third-party OAuth service itself
        if (query.ContainsKey("state"))
        {
            query.Remove("state");
        }

        if (fragment.ContainsKey("state"))
        {
            fragment.Remove("state");
        }

        base.OnPageEncountered(url, query, fragment);
    }
}

当然,这会删除用户的安全警告,但不确定是否有其他解决方法。

关于这一点,游戏进行得有点晚,但我最近遇到了相同的问题,我正试图连接到一个ASP.NET web API

我最终做的是扩展OAuth2Authenticator类并重写OnPageConference。有关Xamarin.Android的实现,请参见以下内容:

public class DroidOAuth2Authenticator : OAuth2Authenticator
{
    ...

    protected override void OnPageEncountered(Uri url, System.Collections.Generic.IDictionary<string, string> query, System.Collections.Generic.IDictionary<string, string> fragment)
    {
        // Remove state from dictionaries. 
        // We are ignoring request state forgery status 
        // as we're hitting an ASP.NET service which forwards 
        // to a third-party OAuth service itself
        if (query.ContainsKey("state"))
        {
            query.Remove("state");
        }

        if (fragment.ContainsKey("state"))
        {
            fragment.Remove("state");
        }

        base.OnPageEncountered(url, query, fragment);
    }
}

当然,这会删除用户的安全警告,但不确定是否有其他解决方法。

我正在尝试使用它,但我得到的OAuth2Authenticator'不包含接受0个参数的构造函数。如何在Xamarin中正确扩展类?我在Xamarin.Auth 1.5上。@user2666194您应该能够用上面的代码扩展OAuth2Authenticator,只需删除。。。。听起来像是在试图调用原始类而不向构造函数传递任何参数。如果您使用以下命令调用它,它应该可以工作:new droidauth2authenticatorclientid:self,scope:,authorizeUrl:newuri…,redirectUrl:newuri。。。;我试图使用它,但我得到OAuth2Authenticator'不包含接受0个参数的构造函数。如何在Xamarin中正确扩展类?我在Xamarin.Auth 1.5上。@user2666194您应该能够用上面的代码扩展OAuth2Authenticator,只需删除。。。。听起来像是在试图调用原始类而不向构造函数传递任何参数。如果您使用以下命令调用它,它应该可以工作:new droidauth2authenticatorclientid:self,scope:,authorizeUrl:newuri…,redirectUrl:newuri。。。;