AuthenticationManager.GetExternalLoginInfoAsync() on google aspnet mvc5 returns null

后端 未结 5 1485
刺人心
刺人心 2021-01-05 00:04

I\'ve developed an ASPNET MVC 5 application using default Visual Studio 2015 Template and Google authentication. All works fine in the development environment but on real th

相关标签:
5条回答
  • 2021-01-05 00:16

    After updating Microsoft.Owin.Security.Google version 4.1.1 (I'm using .NET framework 4.8) it works for me

    0 讨论(0)
  • 2021-01-05 00:18

    Finally (I think that) I've found the solution after a week with no failed login. All thanks to this StackOverflow thread. My solution has been inserting the following line on AccountController.ExternalLogin action:

    Session["Workaround"] = 0;
    

    In the thread above (and links provided there) found a better explanation of the bug when mixing sessions and cookies of ASPNET MVC and OWIN component.

    Full controller service code:

        //
        // POST: /Account/ExternalLogin
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult ExternalLogin(string provider, string returnUrl)
        {
            // https://stackoverflow.com/questions/20737578/asp-net-sessionid-owin-cookies-do-not-send-to-browser
            Session["Workaround"] = 0;
            // Request a redirect to the external login provider
            return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
        }
    
    0 讨论(0)
  • 2021-01-05 00:33

    I updated to version 4.0.1 of the Microsoft.Owin.Security.Google package and I was having the same problem. I was getting null and access_denied. Turns out the problem was due to a space that I had copied over in the Client Secret. It took me 2 days and lots of unnecessary code changes to figure this out. I noticed that when you click copy (not just copy) and paste from Google, there is a space at the end of the Client Secret.

    0 讨论(0)
  • 2021-01-05 00:34

    I faced the Similar Issue with Visual Studio 2017 and .net MVC 5.2.4, Updating Nuget Microsoft.Owin.Security.Google to latest version which currently is 4.0.1 worked for me

    0 讨论(0)
  • 2021-01-05 00:35

    Nothing worked for me tried all above combination...

    But when updated all references dlls with latest on NUGET it worked like charm!!

    0 讨论(0)
提交回复
热议问题