Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LinkedIn authentication issue in eclipse

I AM trying to Integrate LinkedIn with android. Using tutorials I have applied following code...

private void setWebView()
    {
        LinkedinDialog.oAuthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET);
        LinkedinDialog.factory = LinkedInApiClientFactory.newInstance(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET);

        LinkedinDialog.liToken = LinkedinDialog.oAuthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);

        WebView mWebView = (WebView) findViewById(R.id.webkitWebView1);
        mWebView.getSettings().setJavaScriptEnabled(true);

        Log.i("LinkedinSample", LinkedinDialog.liToken.getAuthorizationUrl());
        mWebView.loadUrl(LinkedinDialog.liToken.getAuthorizationUrl());
        mWebView.setWebViewClient(new HelloWebViewClient());

        mWebView.setPictureListener(new PictureListener()
        {
            public void onNewPicture(WebView view, Picture picture)
            {
                if(progressDialog != null && progressDialog.isShowing())
                {
                    progressDialog.dismiss(); 
                }

            }
        });

    }

I get following error at

LinkedinDialog.liToken = LinkedinDialog.oAuthService.getOAuthRequestToken(OAUTH_CALLBACK_URL);




07-22 17:32:08.026: E/AndroidRuntime(26733): FATAL EXCEPTION: main
07-22 17:32:08.026: E/AndroidRuntime(26733): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.devicebee.app.transportfinder/com.devicebee.app.transportfinder.LinkedInActivity}: com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken

I have searched Internet and according to some posts it is because I am under some proxy. But I am pretty sure that I am not under any proxy. Kindly if anyone can tell me what to do. Best Regards

like image 348
Muhammad Umar Avatar asked Nov 13 '22 01:11

Muhammad Umar


1 Answers

Most likely you are trying to run this on your UI thread where network is not allowed. You will need to implement the oauth calls in an AsyncTask.

Network calls on the UI thread were allowed until Android 3.0. The tutorial you are following was probably written before that change happened.

--EDIT-- To test if this is true, you can try setting your application target to API 10 and see if the problem goes away.

like image 129
Error 454 Avatar answered Dec 01 '22 00:12

Error 454