I found the answer myself after a long study.
I changed the base class to linkedin-j
, which can be viewed here here .
Then set these constants as shown below:
public static final String CONSUMER_KEY = "ConsumerKey"; public static final String CONSUMER_SECRET = "ConsumerSecret"; public static final String OAUTH_CALLBACK_SCHEME = "callback"; public static final String OAUTH_CALLBACK_URL = OAUTH_CALLBACK_SCHEME + ":///";
And initialize like this:
LinkedInOAuthService oAuthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET); LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET); LinkedInRequestToken liToken; LinkedInApiClient client; liToken = oAuthService.getOAuthRequestToken(Constants.OAUTH_CALLBACK_URL); Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken.getAuthorizationUrl())); startActivity(i);
This callback is good, and I turned to OnNewIntent:
String verifier = intent.getData().getQueryParameter("oauth_verifier"); LinkedInAccessToken accessToken = oAuthService.getOAuthAccessToken(liToken, verifier); client = factory.createLinkedInApiClient(accessToken); client.postNetworkUpdate("Test");
What all.
source share