1. Back To Blog

Explain MVC OAuth ?(ASP.NET MVC Interview questions)

This MVC Interview question is also asked in a different way "Can we integrate FB and Twitter account authorization with our MVC Application.


One of the most boring process for an end user is registering on a site. Sometimes those long forms and email validation just puts off the user. So how about making things easy by validating the users using their existing facebook / twitter / linkedin / etc accounts. So the user uses something which he already has while the site is assured that this user is a proper user.


This is achieved by using MVC OAuth (Open standard for authorization).



Using MVC Oauth is a three step process:-


  • Register your MVC application / website with the external site i.e. facebook , twitter etc. Once you register your app you get an ID and key from the external site. Below is snap shot of how facebook gives the ID and Key. In FB they term the key as the "App secret". This process varies from site to site. So FB can have X steps while twitter can X+1.



  • Next step is to open "AuthConfig.cs" and you will see lot of readymade code to user your ID and Key. So use the appropriate method as per site and provide the ID and Key.


OAuthWebSecurity.RegisterMicrosoftClient(

                clientId: "",

                clientSecret: "");

 

OAuthWebSecurity.RegisterTwitterClient(

                consumerKey: "",

                consumerSecret: "");

 

OAuthWebSecurity.RegisterFacebookClient(

                appId: "",

                appSecret: "");

OAuthWebSecurity.RegisterGoogleClient();

 


  • Now if you run your application you should get a link to FB login as shown in the below screen. So if you login in FB it will redirect to your MVC application.



You can also see the below video created by Questpond on MVC Web API



Do not miss 100 important MVC Interview question from this codeproject article.


http://www.codeproject.com/Articles/556995/MVC-interview-questions-with-answers

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social