当我尝试使用Facebook或Google登录时,GetExternalLoginInfoAsync始终返回null

亚历山大·芬特克(Oleksandr Fentsyk)

我的OWIN认证有问题GetExternalLoginInfoAsync()当我尝试使用Facebook或Google登录时,总是收到null值

但是有一些神秘的情况。当我打开Fiddler时。我使用这种方法得到正确的数据。

我不知道原因

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

提前致谢!!

亚历山大·芬特克(Oleksandr Fentsyk)

我已经通过添加以下代码解决了我的问题

context.RequestContext.HttpContext.Response.SuppressFormsAuthenticationRedirect = true;

在课堂里:

    private class ChallengeResult : HttpUnauthorizedResult
    {
        public ChallengeResult(string provider, string redirectUri)
            : this(provider, redirectUri, null)
        {
        }

        public ChallengeResult(string provider, string redirectUri, string userId)
        {
            LoginProvider = provider;
            RedirectUri = redirectUri;
            UserId = userId;
        }

        public string LoginProvider { get; set; }
        public string RedirectUri { get; set; }
        public string UserId { get; set; }

        public override void ExecuteResult(ControllerContext context)
        {
            // this line fixed the problem with returing null
            context.RequestContext.HttpContext.Response.SuppressFormsAuthenticationRedirect = true;

            var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
            if (UserId != null)
            {
                properties.Dictionary[XsrfKey] = UserId;
            }
            context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
        }
    }

它解决了我返回的问题NULL

注意:使用Twitter授权登录时不要使用Fiddler。您将收到错误消息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

当我尝试添加图像时,MVC始终返回null

当我尝试使用DynamicMethod创建始终返回true的方法时出现错误

当我尝试使用改造 2 上传图像时,我的 cursor.getString() 返回 null

当我尝试在newtonsoft.json中使用Jsonserialize时,将null返回给字符串

当我尝试强制使用401时,自定义授权过滤器始终返回404

当我尝试使用指针的别名时,g ++返回错误

当我尝试在Java中自动登录Facebook时发生内部服务器错误500

当我尝试登录时,GitHub API 返回消息需要身份验证

在Facebook Integration中,当我单击登录按钮时,它显示正在加载并返回主屏幕?

当我再次尝试登录时,出现此错误:- getter 'uid' 被调用为 null

当我在GridView中使用setOnItemClickListener时返回null

我正在尝试使用Facebook登录,但登录成功,但没有返回到应用程序

当我想通过 google 或 facebook 登录时,如何使场景自动化?

首次登录后,Facebook Profile.getCurrentProfile()始终返回null

当我尝试在 Typescript 中检查字符串值时,此条件将始终返回 true

当我尝试在邮递员中返回消息时,额外的null值

Azure Functions - 当我尝试在本地调试时,配置设置返回 null

无法获得Facebook登录才能在MVC5上运行。它总是在GetExternalLoginInfoAsync()上返回NULL。

除非已登录google,否则在ExternalLoginCallback中使用OWIN的GetExternalLoginInfoAsync null

当我在网站上使用Facebook登录名时可以访问哪些字段?

当我尝试实现登录屏幕时抛出异常

当我使用Action <>设置对象时,分配的对象始终为null

_signInManager.GetExternalLoginInfoAsync() 为 Apple 登录返回 null

当我尝试在React Native中使用AsyncStorage保存值时,但是当我尝试检索值时,我有{“ _U”:0,“ _V”:0,“ _W”:null,“ _X”:null}

当我尝试登录我的应用程序时,Facebook登录按钮才加载

尝试登录时,我的后卫总是在自定义中间件中返回null

无论我尝试使用哪种对象/网站,GetElementById始终返回null

当我尝试使用MS AJAX PageMethods传递对象时,为什么我的参数为null

当我使用Google帐户登录时,Google可以获取哪些信息?