Unable to get public profile url from LinkedIn in Android (BufferedInputStream is closed)
Asked Answered
W

2

6

I am unable to get the public profile url and get or post from the LinkedIn api in Android. I'm using linkedin-j-android source. I'm able to get successful accesstoken but when calling this line from OnNewIntent.

Edited: I have internet permission in my app. So this will not be a problem.

Person profile = client.getProfileForCurrentUser(EnumSet.of(ProfileField.PUBLIC_PROFILE_URL));

 @Override
    protected void onNewIntent(Intent intent) {     

        String verifier = intent.getData().getQueryParameter("oauth_verifier");
        LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier);
        client = factory.createLinkedInApiClient(accessToken);      
        Person profile = client.getProfileForCurrentUser(EnumSet.of(ProfileField.PUBLIC_PROFILE_URL));
        Log.v("","PUBLIC_PROFILE_URL:" + profile.getPublicProfileUrl());
    }

the app crashes. Below is the log trace.

FATAL EXCEPTION: main
com.google.code.linkedinapi.client.LinkedInApiClientException: java.io.IOException: BufferedInputStream is closed
at com.google.code.linkedinapi.client.impl.LinkedInApiXppClient.unmarshallObject(LinkedInApiXppClient.java:167)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.readResponse(BaseLinkedInApiClient.java:3710)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.callApiMethod(BaseLinkedInApiClient.java:3777)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.callApiMethod(BaseLinkedInApiClient.java:3725)
at com.google.code.linkedinapi.client.impl.BaseLinkedInApiClient.getProfileForCurrentUser(BaseLinkedInApiClient.java:1122)

Please help me. Thanks in advance.

Waive answered 18/1, 2013 at 10:22 Comment(2)
Just to be sure, you have the internet permission in your app?Demanding
Yes, i have internet permission.Waive
L
2

is this code snippet working for you :

   Person profile = client.getProfileForCurrentUser();
   Log.v("","PUBLIC_PROFILE_URL:" + profile.getPublicProfileUrl());
Literalism answered 25/1, 2013 at 8:44 Comment(0)
W
0

I'm answering my own question because it may help some people. The code was right from my end, the problem was in intent-filter. android:scheme and android:host mismatch with OAUTH_CALLBACK_URL. When changing this, problem solved.

Waive answered 25/2, 2013 at 11:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.