Asp.net development is an interesting platform and major developers today, are learning and grasping skills to make best development practices. This article is about asp.net developers techniques to authenticate social media in mvc. You will learn every step involved in the process of authentication of FB/Google+ in mvc development.
One of the core functions of any modern web site is the ability to leverage Social Authentication (also known as Social Login).
Normally in any web site we develop there are two common features is there login and registration. In registration we ask basic information to fill from user. And at the back we store user filled information in database and give user unique identification through we identify user when it’s login into our web site. Now a day’s everything is online and most of the work is done through web. So as user point of you, he/she might be go through normal procedure to fill form and register and after registration login and access the web site.
So, Social login is a form of single sign-on using existing login information from an identity provider such as Facebook, Twitter, Google or Microsoft to sign into a third party website and using third party response creating a new login account specifically for your web site.
Social login is actually powered by OAuth. OAuth is an open standard for authorization. OAuth provides client applications 'secure delegated Access’ to server resources on behalf of a resource owner. It specifies a process for resource owners to authorize third-party access to their server resources without sharing their credentials. Designed specifically to work with Hypertext Transfer Protocol (HTTP), OAuth essentially allows access tokens to be issued to third-party clients by an authorization server, with the approval of the resource owner, or end-user. The client then uses the access token to access the protected resources hosted by the resource server. OAuth is commonly used as a way for web surfers to log into third party web sites using their Facebook, Twitter, Google or Microsoft accounts, without worrying about their access credentials being compromised.
To implement login with Facebook in Asp.net web form you might be follow below step.
Login with your Facebook account in below link https://developers.facebook.com/
Create new App
Select Platform of your application or website
Here, we select website.
Create your app name and click on “Create New Facebook App Id”
After that one dialog box open select your app category and click on “Create APP ID”
After that you may see following page that contain your app id.
Now Add your web site url and click on Next.
Now all set, your Facebook app id is created and now we can use this id in our website.Now we implement Login with Facebook in Web Form
And Now Add One Button to invoke request to login with Facebook.
Now All is Done, Login With Facebook is successfully integrate with your Website.
To implement login with Google + in Asp.net web form you might be follow below step.
Login with Google Account in Below link https://console.developers.google.com
Create New Project.
Add Project Name and click on “Create”.
After that you may see the project Dashboard and now you may enable Google + API for your project.
Select Google + API
After selecting Google + API Enable Api and you may see below dialog box appear to get Credential for your project.
Follow all step to get your project credential and finally at the end you get your project Client ID this ID is use in our web page to invoke login with Google + Login request.
Now allset, we can use Generated Client ID in our Web Form. Now Code we have to add in our web form is below.
And Now Add One Button to invoke request to login with Google +.
Now all is Done, Login with Facebook is successfully integrate with your Website. Now At the Back end you have to implement one Method that store information and authenticate user when user came to second time.
Here, in this window user may fill his/her account credential information and click on “Login” so, after click on Login button Facebook is authenticate user and give it back to our app response either positive or negative.
Here above screen is came after when you enter Google account credentials and Google + API ask permission to user to share profile information to the particular site or app.
So, in above screen is the response came from the Google + API. Here response contain user profile information with email and one unique id to identify user. Rest of the other process is same as Facebook so, convert response in JSON Object and invoke particular controller action method to further process the login request. The author has used simple coding and techniques to make you learn the process about authentication of FB/ Google+ in mvc development. This article is purposely intended for asp.net developers and development community, indeed.