final LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(consumerKeyValue, consumerSecretValue);
LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken();
I am using LinkedApi library,Yesterday this code was working but today I don't know why,but its giving exception
LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken();
Its giving :
com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: https://api.linkedin.com/uas/oauth/requestToken
--Solved-- I am posting code so all my friends need not to struggle
Step 1)Get pin by using API
oauthService= LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(consumerKeyValue, consumerSecretValue);
requestToken= oauthService.getOAuthRequestToken();
//requestToken=oauthService.getOAuthRequestToken();
//getOAuthRequestToken("");
autoToken= requestToken.getToken();
authoTokenSecret = requestToken.getTokenSecret();
authUrl= requestToken.getAuthorizationUrl();
Log.i("Tok", autoToken);
Log.i("Tok", authoTokenSecret);
Log.i("Tok", authUrl);
webview.loadUrl(authUrl);
Step 2)webview will show pin after login to linked in now use your pin to got access token and using access token you can get profile and update status
String pin = pin_edit.getText().toString();
System.out.println("Fetching access token from LinkedIn...");
LinkedInAccessToken accessToken = oauthService.getOAuthAccessToken(requestToken, pin);
System.out.println("Access token: " + accessToken.getToken());
System.out.println("Token secret: " + accessToken.getTokenSecret());
final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(consumerKeyValue, consumerSecretValue);
final LinkedInApiClient client = factory.createLinkedInApiClient(accessToken);
Person profile = client.getProfileForCurrentUser();
profile.setCurrentStatus("Hello all my friends ,I am missing you all");
client.updateCurrentStatus("Hello all going");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With