Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Social Login of facebook not working in ASP.Net MVC 5 project

I am going through a tutorial to implement facebook social log in my sample web site. Below are the steps I did.

  1. Pointed my localhost application to https and allowed fake SSL in VS.
  2. Created a web app in facebook developer web site and noted down the secret key and id.
  3. Added my application localhost URL in the URL section of the dashboard in facebook
  4. I added key and id in the starup.Auth.cs file in my ASP.Net MVC-5 project .

Behavour: Now when I run my application from local host (https) and click Register then I see the facebook sign in button. Also when I click that button a facebook pop up comes with "Sample App" wants to access your facebook data. So far so good. But as I say YES to it nothing happens after that. I get redirected to the log in page. and the URL is https://localhost:44393/Account/Login#_=_

Expected Behaviour: For the tutorial that I am following after doing above steps one message comes on tutors screen as "Facebook has authenticated.... Enter you email to continue". Something like this. Can some one please guide me here why I am not getting same message and why I am not able to use social log in. I have tried to follow all the steps.

Expected Screenshot from tutorial enter image description here

Is there any other steps I need to do in facebook developer dashboard?

EDIT 1 :

In the facebook developer dashboard for my app in the Facbook Login Tab->Settings : I see below message.

enter image description here

EDIT 2: I debugged and found that returnURL is null when I click on facebook log in button.

   [AllowAnonymous]
        public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
            if (loginInfo == null)
            {
                return RedirectToAction("Login");
            }

            // Sign in the user with this external login provider if the user already has a login
            var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: false);
like image 303
Unbreakable Avatar asked Jan 22 '26 09:01

Unbreakable


2 Answers

Ok, After research I found out that I need to install package Install-Package Microsoft.Owin.Security.Facebook from nuget package manager. After this everything worked fine.

like image 141
Unbreakable Avatar answered Jan 25 '26 00:01

Unbreakable


Simply update the Windows.Owin.Security.Facebook to latest version(3.1.0) further in facebook application update the "Valid OAuth redirect URIs" to "http://localhost:xxxx/signin-facebook" (in my case) every thing works...

OR

Please see the link ExternalLoginConfirmation returns null after facebook succesful login

like image 41
Asad Shakeel Avatar answered Jan 25 '26 00:01

Asad Shakeel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!