11

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#)

Community
  • 1
  • 1
Nak Android Dev
  • 687
  • 1
  • 8
  • 24

4 Answers4

5

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

Himanshu Agarwal
  • 4,369
  • 5
  • 34
  • 49
0

Access to full profile data and connections is limited to developers that are participating in certain LinkedIn partner programs, so you will not be able to request an access token that grants you that information unless you are in such a program.

If you are a partner, you should follow up with your LinkedIn partner engineering rep. If are not, you can apply to become a LinkedIn partner here: https://developer.linkedin.com/partner-programs/apply

Justin Kominar
  • 3,246
  • 1
  • 12
  • 14
0

For basic information you can inspect the queries LinkedIn's front-end does when displaying profile and connections so you can just make the same calls and use the JSON response in your app. You can even use the search call to find the profile link.

Vlad Teodor
  • 112
  • 8
  • how to make that request and fetch JSON response ? I am calling https://api.linkedin.com/v1/people/~ and you can see response in question above. – Nak Android Dev Sep 04 '15 at 06:24
0

Its easy, just call it like that:

https://api.linkedin.com/v1/people/~?oauth2_access_token=ACCESS-TOKEN-GOES-HERE
Mohammad AL-Raoosh
  • 711
  • 1
  • 10
  • 30