4

I am trying to get the access token for LinkedIn Here's the part of code,

OAuthService service = new ServiceBuilder().provider(LinkedInApi.class).apiKey("My_Api_Key").apiSecret("My_secret_key").build();

System.out.println("LinkedIn Service created");         
Token token = service.getRequestToken();

System.out.println("Got Request token");            
System.out.println(service.getAuthorizationUrl(token));
//https://api.linkedin.com/uas/oauth/authorize?oauth_token=some_value
Verifier verifier = new Verifier("verifier_you_got_previously");

I am able to obtain a request token, and the authorization url which is https://api.linkedin.com/uas/oauth/authorize?oauth_token=some_value To get the Verifier object, I need to pass the verifier value to the constructor. How do I obtain this value? This is a oob request, so there's no callback set to the service. What should I do with the authorization Url to get the oauth_verifier?

Umesh Awasthi
  • 23,407
  • 37
  • 132
  • 204
Janhavi
  • 55
  • 1
  • 5

2 Answers2

5

Your server doesn't get the verifier. You need to redirect your user to the authorizationUrl, then ask them to provide it to you somehow.

This is how OAuth works, you can't trick the system.

Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232
  • 4
    @Pablo, I don't understand how this works. I have successfully load the authorizationURL in a webview, then the user has logged in, and now I get a page with a textbox and the authorization code in it. How do I get the verifier? Mine does not exist in the URL. I just have the [code]. I am using Scribe. – Eenvincible Feb 03 '14 at 20:01
  • @Eenvincible do ypu want to add anything here. got any solution – Shubham AgaRwal Feb 02 '16 at 09:39
  • Uri uri = this.getIntent().getData();String code = uri.getQueryParameter("code"); Verifier verifier = new Verifier(code); then use it inside an AsyncTask - remember this code is obtained inside onResume after the request has resumed. – Eenvincible Feb 02 '16 at 18:52
0

Use HTTP Client for POST request to authorization URL.

Abhendra Singh
  • 1,959
  • 4
  • 26
  • 46