ASP.NET Core Authentication and Authorization – Part 2

Hi Friends,

In this section, I will continue from the last section and delve further into authentication. Now, let’s bring some OAuth capabilities into the application. So, the first change, I need to make here is to include the required packages in project.json file. Here, I will show another technique to add the required packages. We already know this technique and this is via Nuget Package Manager as shown below in the screen shot.

234th

Similarly, I installed many other account packages like shown below.

235th

Similar thing I can verify in my project.json file.

236th

Now, before setting the MiddleWare, I also need the App-ID and Secret Key. For doing so, let us go to https://developers.facebook.com/apps

Here, I need to click on Add New App as shown below in the screenshot.

237th

Then, we will select website from the below options.

238th

Then, I will just provide the mandatory details and fill the required things up like shown below

241th

Then, I will just give the URL detail as shown below.

242nd

Then, I will click on next on go on developer’s dashboard page like shown below. Here, I have omitted APP-ID and Secret Key for obvious reasons. Now, these keys, I will make use in my application.

243rd 244th

So, FB setup is done. Now, its time to setup the Middleware, which we have installed. As a best practice, we should be using secret manager to store the key so that it won’t get checked in with the source control. But, for demo its ok to have here.

245th

With this change in place, when I go to my app, it will present me Facebook link over there.

246th

And, when I click on facebook button, it will take me to Facebook authentication page.

247th

Here, I will provide my credentials and login, it will present me below page.

248th

Then, I will provide some email id which I want to identify as FB authenticated person like shown below.

250th

And, if I click on the my profile, it will present all the external logins associated with the app as shown below.

251th

I hope you would have liked this discussion. In the coming section, we will delve further. Thanks for joining me.

Thanks,
Rahul Sahay
Happy Coding

2,313 total views, 1 views today