Search code examples
asp.net-mvcasp.net-identity

How to incoporate facebook login MVC 5 identity 2?


In an account controller there is ExternalLogin action.

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider, string returnUrl)

I have appId and appSecrete set in StartUp. I'm running my application in local machine(localhost:port). I have custom facebook button(normal button).

I do not understand how I can call the external login from the button since the action above requires provider and return url. There is already ExternalLogin callback action as well.

When setting facebook application, I seem not to understand this part: Valid OAuth redirect URIs.

Please somebody help. The articles I read confuse me in this regard.

Edit: I can now connect to facebook, the only problem is I get an error:

URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.

I believe it is caused by Valid OAuth redirect URIs which is not set correctly.


Solution

  • Go to you facebook app development website. Open your page. Go to Facebook Login option under it go to setting option and change your Valid OAuth redirect URL. you have to give your website valid path in that section.

    enter image description here

    For local host you can try like this -

    http://localhost:8080/fb_login_local/