0
votes

I have used the linkedin-j-android.jar of version 1.0.429 in my android project

here is the link for downloading patched linkedin-j-android.jar with scope fix http://db.tt/yQjhqeq3 below is the code which i have used in my project:

class  ShowNetWorkUtils{
    public static final String CONSUMER_KEY =    "xxxxx"; 
    public static final String CONSUMER_SECRET = "yyyy";
    public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-linkedin";
    public static final String OAUTH_CALLBACK_HOST = "calback";
    public String scopeParams="rw_nus+r_baseprofile";
    public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME
            + "://" + OAUTH_CALLBACK_HOST;

    private void configureLinkedIn() {
    new Thread(){
    @Override
    public void run() {
    try {
    Looper.prepare();
    LinkedInOAuthService  oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService       (CONSUMER_KEY,CONSUMER_SECRET,scopeParams);
    LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(CONSUMER_KEY,CONSUMER_SECRET);

    LinkedInRequestToken liToken = oauthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);

 //LinkedInRequestToken liToken = oauthService.getOAuthRequestToken();

    String url = liToken.getAuthorizationUrl();

 /*  For Linkedin dialog create and show     */

     LKDialog lkdDialog = new LKDialog(_context, url);
     LKDialog lkdDialog.setDelegate(ShowNetWorkUtils.this);
     LKDialog lkdDialog.show();
    Looper.loop();
    }
    catch (Exception e) {
       e.printStackTrace();                     
       }

    }      //End run
         }.start();
     }

}  //End Class

I am getting the exception when i request for the token in line "oauthService.getOAuthRequestToken(OAUTH_CALLBACK_URL)" and also i have used "oauthService.getOAuthRequestToken()" but i am getting the same exception in this case also.

The exception is : com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken?scope=rw_nus+r_baseprofile

please provide me some solution to solve this..

1

1 Answers

0
votes

Replace the following line in your code

  public String scopeParams="rw_nus+r_baseprofile";    

with

   public String scopeParams="rw_nus+r_basicprofile";

Because the permission scope is r_basicprofile but you have written as r_baseprofile

Hope it will help you.