Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user data after Login with LinkedIn

I have implemented login with LinkedIn and I am getting access token after successful login by session.getAccessToken().toString(). Now I need complete user profile and his connection list in account. But I am unable to retrieve that information from LinkedIn.

I am calling its REST client API call that was stated in official document like this

https://api.linkedin.com/v1/people/~

In this I am passing my access token as oauth2_access_token that I got after login. But in response i am getting

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
    <status>401</status>
    <timestamp>1440998578838</timestamp>
    <request-id>P6GDCHJ13P</request-id>
    <error-code>0</error-code>
    <message>Unable to verify access token</message>
</error>

I have already tried various solutions like stated here:

LinkedIn OAuth2: "Unable to verify access token"

https://github.com/lepture/flask-oauthlib/issues/35

How to Retrieve all possible information about a LinkedIn Account ? (API using C#)

like image 609
Nak Android Dev Avatar asked Aug 31 '15 06:08

Nak Android Dev


People also ask

What data can you extract from LinkedIn API?

Using the API for LinkedIn, you can get detailed information about LinkedIn groups based on the ID of the target groups. Below are some of the data you can get: ID, name, date of creation, logo, description, location, industries, etc. Learn more in the LinkedIn API documentation.


1 Answers

As per official documentation it's stated that to make LinkedIn REST API calls you need to call by APIHelper.getRequest() method or APIHelper.postRequest() for GET and POST call respectively; and fetch all requested data of the user you need to make REST URL that are already given in their documentation. Here's the quick example to fetch user basic_profile data:

String url = "https://api.linkedin.com/v1/people/~:(id,first-name,last-name)";

APIHelper apiHelper = APIHelper.getInstance(getApplicationContext());
apiHelper.getRequest(this, url, new ApiListener() {
    @Override
    public void onApiSuccess(ApiResponse apiResponse) {
        // Success!
        Log.d("linkedin response for data", apiResponse.getResponseDataAsJson().toString());
    }

    @Override
    public void onApiError(LIApiError liApiError) {
        // Error making GET request!
    }
});

You can refer official documentation over here for complete detail

like image 190
Himanshu Agarwal Avatar answered Sep 23 '22 22:09

Himanshu Agarwal