Part 2: Using SocialAuth to Integrate LinkedIn API in Android

LinkedIn is one of the most popular social networking platforms available today. LinkedIn users can share status updates, respond to topics of interest, read the latest updates from contacts and companies, and participate in group discussions about topics that interest them. The popularity of social networking platforms like Facebook, LinkedIn, and Twitter means that mobile app developers are tightly integrating these services with their applications to allow users to share content on these sites without ever leaving an application. Although there are solutions available to integrate LinkedIn with Android applications , the implementation process is quite difficult and restricts use with other social networks.

SocialAuth Android is an easy to use open source SDK that allows mobile developers to create apps that integrate with LinkedIn. It provides simple code to access its various functionalities, along with free support, and it is one of the few SDKs that can help integrate other social networks in your Android app, along with LinkedIn.

Using this SDK you can share your status, get user profile and list of connections.

Getting Started

First you need to register your application with LinkedIn, and get the API keys and secret keys. The following link will help you to get these:

Integrate SDK in App

Now we can start integrating the SDK, which can be downloaded from This SDK contains the Java libraries that do the heavy lifting of OAuth as well as the REST calls for each social provider. Extract the contents and we are all set.

  1. Copy the libs/socialauth-android-2.5.jar and libs/socialauth4.2 jar into the libs folder of your application. If you have the latest Android Development Tools (ADT), jars will be automatically added to your build path. If not, you will need to manually add the jar files in build path. We recommend you upgrade to the latest ADT.
  2. Copy the assets/ file to the assets folder of your application. The file is used by the SDK for the API and secret keys. Replace the default entries with the keys generated by following the above steps.
  3. Add  android.permission.INTERNET and android.permission.ACCESS_NETWORK_STATE in manifest.

That is all you need to get started. The SDK .zip file also contains code samples which can help you go ahead with the coding.


You just need to click button and it will open a LinkedIn login dialog box. After user authorization is completed you can get options to various functionalities.

LinkedIn login dialog box



Initialize the SocialAuth Adapter Object and create a LinkedIn button. After clicking the button, give the required authorization to the adapter.

 public void onCreate(Bundle savedInstanceState) {
       adapter = new SocialAuthAdapter(new ResponseListener());
      linkedin_button = (Button)findViewById(;
     facebook_button.setOnClickListener(new OnClickListener() 
        public void onClick(View v) 
            adapter.authorize(ProviderUI.this, Provider.LINKEDIN);

Receive Authentication response in ResponseListener and initiate calls to get various functionalities.  See Examples below:

Update Status

Share your status by calling adapter.updateStatus() and verify response in MessageListener. You can share your status on your LinkedIn account in any language.

private final class ResponseListener implements DialogListener 
   public void onComplete(Bundle values) {
      adapter.updateStatus(edit.getText().toString(), new MessageListener());                   

// To get status of message after authentication
private final class MessageListener implements SocialAuthListener {
    public void onExecute(Integer t) {

    Integer status = t;
    if (status.intValue() == 200 || status.intValue() == 201 ||status.intValue() == 204)
     Toast.makeText(CustomUI.this, "Message posted",Toast.LENGTH_LONG).show();
    Toast.makeText(CustomUI.this, "Message not posted",Toast.LENGTH_LONG).show();

Get Profile

Get User profile by getUserprofileAsync() method and receive response in profileDataListener. You can get

User profile ID, first name , last name , email, country, language , location and profile image URL for LinkedIn.

private final class ResponseListener implements DialogListener 
   public void onComplete(Bundle values) {
      adapter.getUserProfileAsync(new ProfileDataListener());                   

// To receive the profile response after authentication
private final class ProfileDataListener implements SocialAuthListener {

public void onExecute(Profile t) {

   Log.d("Custom-UI", "Receiving Data");
   Profile profileMap = t;
   Log.d("Custom-UI",  "Validate ID         = " + profileMap.getValidatedId());
   Log.d("Custom-UI",  "First Name          = " + profileMap.getFirstName());
   Log.d("Custom-UI",  "Last Name           = " + profileMap.getLastName());
   Log.d("Custom-UI",  "Email               = " + profileMap.getEmail());
   Log.d("Custom-UI",  "Country                  = " + profileMap.getCountry());
   Log.d("Custom-UI",  "Language                 = " + profileMap.getLanguage());
   Log.d("Custom-UI",  "Location                 = " + profileMap.getLocation());
   Log.d("Custom-UI",  "Profile Image URL  = " + profileMap.getProfileImageURL());

Get Contacts

Get User contacts by getContactListAsync() method and receive response in contactDataListener. You can get first name, last name and profile URL for LinkedIn.

private final class ResponseListener implements DialogListener 
   public void onComplete(Bundle values) {
      adapter.getContactListAsync(new ContactDataListener());                   

// To receive the contacts response after authentication
private final class ContactDataListener implements SocialAuthListener> {

public void onExecute(List t) {

   Log.d("Custom-UI", "Receiving Data");
   List contactsList = t;
  if (contactsList != null && contactsList.size() > 0) {
  for (Contact c : contactsList) {
    Log.d("Custom-UI", "Contact ID = " + c.getId());
    Log.d("Custom-UI", "First Name = " + c.getFirstName());
    Log.d("Custom-UI", "Last Name = " + c.getLastName());


That’s the overview of how to download and install SocialAuth Android to easily integrate LinkedIn with your Android applications. For the next and last post in the series, we’ll cover how to integrate the Twitter API in Android applications using SocialAuth. If you have questions or need support, feel free to leave comments on the main SocialAuth Android page.

Vineet Aggarwal

Vineet Aggarwal

Sr. Technical Lead

Vineet Aggarwal is a Sr. Technical Lead at 3Pillar Global Labs, which is part of 3Pillar’s company strategy in the fields of big data analytics, mobility, and cloud-based applications. Vineet leads development and support for the popular open source tool SocialAuth–Android. He also leads our Android Competency Center in India and is responsible for mentoring Android Developers across the company to develop internal expertise. He has hands-on experience with various mobile platforms and keen interest in Android and iPhone. He loves designing new apps, learning upcoming technologies, and mentoring members of the Android community.

6 Responses to “Part 2: Using SocialAuth to Integrate LinkedIn API in Android”
  1. Ashish on

    Hi Vineet,

    I have integrated Facebook, Twitter in my android native app. both are working fine as expected but when i integrated Linkedin with Socialauth (same) library then getting an error like “ URL Authentication error” I googled lot but could not find a solution. I am using socialauth-4.8.jar and socialauth-android-3.2.jar files.

    your help will be appreciated.

    Ashish C

    • archit on

      hi i am trying to integrate facebook SDK,in my login i am not getting the gradle build in the facebook SDK file could you please suggest url form where you downloaded facebook SDK
      and how you unzipped the file.

      and trying with twitter integration in this so many error are coming in my project.
      socialauth-4.4.jar files
      not getting 3.2.jar file

      • Zain Ali on

        i am facing the same problem and i solve it by following steps.
        1)file new module
        then enter the path it will give u error if u using android studio not eclipse so to need to select the rar file from the sdk folder then .
        if this solve in your case then file other wise make a new solder in project directory and copy the file of sdk there and then in setting of gradle include the file name. so it is solved!
        for further query email me

  2. Himansu on

    Hi Vineet,

    Thanks for the nice tutorial. It’s very helpful!

    I am facing one issue while fetching LinkedIn contact list. Below is the error I am getting;
    “org.brickred.socialauth.exception.ServerDataException: Failed to parse the contacts from response.,first-name,last-name,public-profile-url,picture-url)

    Would appreciate your help here.

    Thanks in advance!

  3. Ujjwal on

    Hey Himanshu,
    I am getting the same error as you, its because contact list is not getting fetched and null. Seems like some API restriction created by LinkedIn recently. So, Vineet, do you have any solution to fix this please.


  4. Suraj Sahijwani on

    Hi, is this incomplete code or what? Nothing happens on button click, I do not get error nor it asks for authentication with LinkedIn app. Please can you post full code for reference. Thanks!

Leave a Reply

Related Posts

Building a Microservice Architecture with Spring Boot and Do... This is the first post in what will be a 4-part series on building a microservice architecture with Spring Boot & Docker. This post will provide a...
Building a Microservice Architecture with Spring Boot and Do... Part II: Getting Set-Up and Started Introduction and Tools In this part, we'll get to work on building out the solution discussed in Part I. I'm goi...
Building a Microservice Architecture with Spring Boot and Do... Part III: Building Your First Microservice, its Container, and Linking Containers We're about ready to actually get started with building a microserv...
Building a Microservice Architecture with Spring Boot and Do... This is the fourth blog post in a 4-part series on building a microservice architecture with Spring Boot and Docker. If you would like to read the pre...
Innovation Wars, with Scott Bales Scott Bales joins us on this episode of The Innovation Engine to dive into the concept of "innovation wars." Among the topics we'll discuss are what c...


Sign up today to receive our monthly product development tips newsletter.