How to make authenticated calls to the LinkedIn API using the Spring.net Social Extension for LinkedIn

I just spent way too much time trying to figure out how to call the LinkedIn People Search API. I needed to simply use the LinkedIn API to find people in my network by their full name. The last thing I want to do is try to figure out how to get OAuth working when I have a thousand other things to do. I downloaded all the C# libraries I could find, but most required a bunch of setup or compiling or hacking that I don’t have time for. I then came across the Spring.net Social Extension for LinkedIn. I went over to the SpringSource LinkedIn GitHub page and found this sample. It looked pretty straight forward so I decided to go for it…and got it working in about 10 minutes.

Here’s what I did:

  1. Created my LinkedIn app. https://www.linkedin.com/secure/developer?newapp=

  2. Created a new C# project and referenced Spring.Social.LinkedIn via nuGet

  1. Referenced Common.Logging (I actually did this later because I was getting an exception, but just do it now)

  1. Copied the 4 following strings into my project:
private const string LinkedInApiKey = "[copy from your linked in app details page]";
private const string LinkedInApiSecret = "[copy from your linked in app details page]"; 
private const string LinkedInUserToken = "[copy from your linked in app details page]"; 
private const string LinkedInUserSecret = "[copy from your linked in app details page]"; 
  1. Created this SearchAsync method
public async Task<LinkedInProfiles> SearchAsync(string queryText)
&#123;
     var l = new LinkedInServiceProvider(LinkedInApiKey, LinkedInApiSecret);
     var a = l.GetApi(LinkedInUserToken, LinkedInUserSecret);
     var sp = new SearchParameters() &#123; Keywords = queryText &#125;;
     return await a.ProfileOperations.SearchAsync(sp);
&#125;

6. Called SearchAsync method from another method

var p = SearchAsync(queryText);
foreach (LinkedInProfile pr in p.Result.Profiles)&#123;&#125;

I hope this saves you some time.

Jon