Here i will explain about how to implement Linkedin authentication in ASP.NET MVC. In order to use API in our web application, first you need to create an application in Linkedin Developer Page. The following are the steps to follow to create an application in Linkedin.
Click on API Keys and then you will see an list of your applications. Now click on Add new Application
Next create your application settings
Once application is created save the API Key and Secret Key in APP Settings under Web.config file
We have succesfully created the Linkedin application, now we need to enable the LinkedIn authentication in ASP.NET MVC.
Integrtating LinkedIn Authentication ASP.NET MVC
The following are the steps you need to follow for enabling the LinkedIn authentication in ASP.NET MVC.
By default, Extrenal authentication in ASP.NET supports only MicrosoftAccount, TwitterAuthentication, FacebookAuthentication, and GoogleAuthentication but we need to use LinkedIn authentication for that we need to install a package from the nuget called Owin.Security.Providers.
Step 1: Execute the following command in the Nuget Package Manager Console(Click on Tools —> Nuget Package Manager —> Package Manager Console)
Step 2: In the web.config file add the API Key and Secret Key under app settings
<add key="LinkedInAPIKey" value="759ovbpv5qvg25" /> <add key="LinkedInAPISecret" value="j3Arp8J6y9CPwXhq" />
Step 3: Now go to App_Start/Startup.Auth.cs to enable the Linked Authentication
app.UseLinkedInAuthentication ( clientId: ConfigurationManager.AppSettings["LinkedInAPIKey"].ToString(), clientSecret: ConfigurationManager.AppSettings["LinkedInAPISecret"].ToString() );
Step 4: Everything is configured so now run the web application to test it.
Now Click on Login
Now Click on the LinkedIn button to login using LinkedIn API. The page will be redirected to the LinkedIn Login screen
Click on the Register button to complete the registration process.