Click here to Skip to main content
15,886,101 members
Articles / Web Development / HTML

LinkedIn Authentication in ASP.NET MVC

Rate me:
Please Sign up or sign in to vote.
4.40/5 (4 votes)
9 Feb 2015CPOL2 min read 20.7K   9   4
Here, I will explain about how to implement Linkedin authentication in ASP.NET MVC.

Introduction

Here, I will explain how to implement Linkedin authentication in ASP.NET MVC. In order to use API in our web application, first we need to create an application in Linkedin Developer Page. The following are the steps to follow to create an application in Linkedin.

Register Application

Image 1

Register your application in linkedin developers page

Click on API Keys and then you will see a list of your applications. Now click on Add new Application.

Image 2

Add new application in linkedin

Next create your application settings.

Image 3

LinkedIn Application Registration

Image 4

Developer Network Application Details LinkedIn OAuth Settings

 

Once application is created, save the API Key and Secret Key in APP Settings under Web.config file.

Image 5

We have successfully 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, external 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).

Install-Package Owin.Security.Providers

Step 2

In the web.config file, add the API Key and Secret Key under app settings:

XML
<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.

C#
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.

Image 6

Now Click on Login

Image 7

Now click on the LinkedIn button to login using LinkedIn API.

The page will be redirected to the LinkedIn Login screen.

Image 8

Now click on Allow access button to log into the LinkedIn. After login, you will be redirected back to the application.

Image 9

Click on the Register button to complete the registration process.

The post LinkedIn Authentication in ASP.NET MVC appeared first on Venkat Baggu Blog.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) eBiz Solutions http://venkatbaggu.com/
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow user get redirected to Linkedin Login page ? What is code behind "linkedin" button ? Pin
Lavkush3917-Mar-17 3:10
Lavkush3917-Mar-17 3:10 
QuestionStartup.Auth.cs missing Pin
Chamith Saranga7-Feb-16 16:07
Chamith Saranga7-Feb-16 16:07 
QuestionUseLinkedInAuthentication Pin
Member 120699517-Dec-15 22:28
Member 120699517-Dec-15 22:28 
GeneralMy vote of 4 Pin
Gaston Verelst10-Feb-15 22:22
Gaston Verelst10-Feb-15 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.