Introduction :

Being Easy to have your users authenticate using Google, Facebook, Twitter, etc is a great way to remove the annoyance of having to create a local account and go through the email validation process. Here we can access the website using Facebook  Login.

Requiring a user to create a local account and confirm an email address might be enough for a user to go away. Especially if something goes wrong with the confirmation email. For example, if it takes a bit too long for the email to get to the user’s inbox.

Trending Now :  Understanding Asp.Net Ajax

It is  very simple to setup social logins. In this Article discribes a step by step guide into how you can enable a user to login to your website using Facebook using just ASP.NET Core and then, using ASP.NET Core Identity.

Step 1 . Registering your website with Facebook

Facebook needs to know about your website.

To do that go to FB Developer page and click Register Now on Become a Facebook Developer.

Facebook

There are a few steps in the registration process that you have to go through that will lead to you being asked to create an AppId

Facebook

An AppId is an identifier that Facebook uses to identify your website or web application. When your website redirects a user to Facebook for the user to sign in, the redirect will contain the AppId. Here Fb displays  a confirmation screen to your user with the application name.

Click Here For Dot Net Useful Resources

Here name your web application, and get an AppId

 Facebook

Now ,You should see a screen and that on the top left corner has the AppId:

Facebook

Click the Get Started button on the Fb Login

Facebook

Get started here add your website URL,and then you use localhost for development.

 

Facebook

You now have an App Id and an App Secret which is all you need to enable social  network logins using Facebook.

Facebook

Also Read : ASP.NET MVC Overview

Setup Facebook login in your ASP.NET MVC :

Code Example :

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)

{

app.UseCookieAuthentication(new CookieAuthenticationOptions

{

AuthenticationScheme = “ApplicationCookie”,

AutomaticAuthenticate = true

});

app.UseFacebookAuthentication(new FacebookOptions

{

AuthenticationScheme = “Facebook”,

AppId = “YOUR_APP_ID”,

AppSecret = “YOUR_APP_SECRET”,

SignInScheme = “ApplicationCookie”

});

app.UseStaticFiles();

app.UseMvc(routes =>

{

routes.MapRoute(

name: “default”,

template: “{controller=Home}/{action=Index}/{id?}”);

});

}

Conclusion :

And this concludes the description of how using a external login provider works in ASP.NET Core, both using only authentication middleware and using ASP.NET Core Identity.

Click here for more updates on FREE DOT NET TUTORIALS

About our Dot Net Training in Chennai

Credo Systemz provides dot net training in chennai for both beginners and experienced professionals in a expert way, Our Dot Net Training course content is designed in a way which is real time practical oriented training. Exclusive offers available for Fresher/Student. Book a FREE DEMO session with our Dot Net Trainer.