Android Linkedin API with OAuth Authentication (Using Scribe-Java Library)

As Linkedin is one of the professional social media network, most of us needs to access there web services to collect data.
In this post I would like to give simple examples on how to get logged in user information such as email, full name, friends list. And I'm planning to update this post with the sending messages and share posts.

There is no official SDK provided by the Linkedin developer support. They have recommended to use Scribe library (By Pablo Fernandez), which will helpful to do the OAuth authentication with Linkedin web services. This library can be used for most of the web services, where they use OAuth authentication.

In this example still I'm using OAuth 1.0 as default authentication.

First we have to add the Scribe dependancy to build.gradle
dependencies {
  compile 'org.scribe:scribe:1.3.+'
}

We have to create an application to access Linkedin API's. For that go to Developer Console and Add New Application. After creating the application you can find your Consumer Key and Consumer Secret Key. Keep in mind not to share them with others. You can see them on below image.



In the above image I have colored all the OAuth keys:) It's recommend only to keep secret Consumer Secret and OAuth 1.0a User Secret only. For this application to work as expected, we have to enable required Scopes. In above image you can see them in OAuth User Agreement section. (If you enable r_fullprofile, then it is redundant to enable r_basicprofile).

I have uploaded my example code in to Github and in there you have to change the Consumer key and Consumer Secret key to match your application. In this example application I have added two Product Flavors called Dev and Prod. You can use different Linkedin applications for each product flavor.


public class ProductFlavourConstants{

    public static final String LINKEDIN_CONSUMER_KEY = "YOUR_PROD_CONSUMER_KEY";
    public static final String LINKEDIN_CONSUMER_SECRET = "YOUR_PROD_CONSUMER_SECRET";

}

Comments

Unknown said…
hi thanks for sharing! you might also be interested in exploring more about mobile app development Singapore

Popular posts from this blog

SSL Pinning in Android

Java Unit testing using JUnit @RunWith(Suite.class)

Android Event Bus Implementations using Otto