I’m using LinkedIn OAuth in my Android app. I’ve an LinkedIn application, consumer key and secret already, an as a result I can request succesfully.
Everything is fine until callback. The web page not calling back, I mean onNewIntent or onResume methods not calling. Web page only shows callback url with parameters. I mean it looks like:
callback_url://?oauth_token=324sdf&oath_verifier=as21dsf
Here is my all code:
try {
consumer = new CommonsHttpOAuthConsumer("ConsumerKey", "ConsumerSecret");
provider = new CommonsHttpOAuthProvider("https://api.linkedin.com/uas/oauth/requestToken", "https://api.linkedin.com/uas/oauth/accessToken", "https://api.linkedin.com/uas/oauth/authorize");
final String url = provider.retrieveRequestToken(consumer, Constants.OAUTH_CALLBACK_URL);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
Activity is already defined as singleInstance in Manifest.
What’s wrong or missing?
I’ve found the answer myself after a long research.
I’ve changed my base class to
linkedin-jwhich can be looked at here.Then set this constans as below:
And initialize like that:
This callbacks well and I’ve handled at OnNewIntent:
That’s all.