ASP.NET MVC: LinkedIn integration

First of all, want to say that in the created by default ASP.NET MVC 4.5 application we already have ability for simply enabling of integration with differences social networks. Let’s create not empty ASP.NET MVC 4.5 application, and enable existing social-networks buttons, just uncomment out next things in the App_Start/AuthConfig.cs

            //    clientId: "",
            //    clientSecret: "");

            //    consumerKey: "",
            //    consumerSecret: "");

            //    appId: "",
            //    appSecret: "");


So, after you have filled out clientId, clientSecret, consumerKey, consumerSecret, appId and appSecret you can log into the system through Microsoft, Twitter, Google and Facebook accounts.   For adding LinkedIn button, you ought to add RegisterLinkedInClient() to the App_Start/AuthConfig.cs file. For getting ApiKey and SecretKey need to do next steps:

1) Add your application here

add new application

2) After you are created app, you need these ones

linkedin application details

now you can register LinkedIn client

                consumerKey: "tq84whxs64bi",
                consumerSecret: "h8ghO3vdouLleDFG");

but you will get exception: “The remote server returned an error: (400) Bad Request.” after you have clicked by “LinkedIn” button

linkedin button

So, why LinkedIn does not work for created by default ASP.NET MVC application? The answer is here. Thank you Mr. Roa, you are saved many time for me, I owe you a beer!

And a couple of things yet:

in the LinkedInCustomClient there is profileRequestUrl const, if you want to get only basic information about user profile like firstname, lastname, company, next request will be good approach for you

const string profileRequestUrl = ",first-name,last-name,headline,industry,summary)";


But if you want to grab more info such as email address or user’s profile photo url, you have to use next query,  this one involves a lot of user profile data::

 const string profileRequestUrl = ",first-name,last-name,headline,industry,summary,picture-url,email-address,date-of-birth,phone-numbers)";

You also have to add scope to the RequestTokenEndpoint, and you’ll able to read such info as email address etc.

please change next strings in the LinkedInCustomClient.cs, set for RequestTokenEndpoint next value

RequestTokenEndpoint = new MessageReceivingEndpoint(" r_emailaddress r_contactinfo rw_nus", HttpDeliveryMethods.PostRequest),


Source code (VS2012):

  • Nits Patel

    Amaizing example this is…. Thanks a lot dear for this post………

    • Sergey Boiko

      You are welcome!

  • dev account

    awesome post. after searching 2 days finally I got you. thanks a lot………

    • Sergey Boiko

      it is nice to hear, thanks!