0

I try to log in with linkedIn API. But i get exception:
401 for URL: https://api.linkedin.com/uas/oauth/requestToken

I used this example : http://karanbalkar.com/2013/09/tutorial-57-connect-to-linkedin-using-java-and-oauth/

There is something with this path http[s]://api.linkedin.com/uas/oauth/requestToken

This piece of code call exception:

LinkedInRequestToken requestToken= oauthService.getOAuthRequestToken();

But it doesn`t work. Please, help me!

user3661720
  • 27
  • 12

1 Answers1

1

I would say that for a 401 at that point in the code, probably the key and/or secret are incorrect when you do

createLinkedInOAuthService(linkedinKey, linkedinSecret)

Please verify that you have the correct values in your code.

demongolem
  • 9,474
  • 36
  • 90
  • 105
  • linkedinKey - my email, that i use for linkedin, linkedinSecret - my password for linkedin. Am I right? Skype: flexin777. – user3661720 May 23 '14 at 06:59
  • Could you give me you example of code that you use to sign in, please? – user3661720 May 23 '14 at 07:05
  • There is also error like: Response: 401 Unauthorized 401 1400841395841 INP1TFA5R4 0 [unauthorized]. No consumer found for key vadym.morozov89@gmail.com – user3661720 May 23 '14 at 10:38
  • @user3661720. In response to your first comment, no I think you are mistaken on what your key and secret are. You have to go and create an API key and secret for a specific Application (your program you are developing). Go to https://developer.linkedin.com/documents/authentication for a step-by-step guide to do this. There is a link (look for word Register which is a hyperlink) to the page where you do this Application registration. It will ask you for you linkedin username/password and you follow the instructions from there. – demongolem May 23 '14 at 12:57
  • Thank you! I registred it. Could you tell me what does "pin" mean there(I used this example : http://karanbalkar.com/2013/09/tutorial-57-connect-to-linkedin-using-java-and-oauth/)?: LinkedInAccessToken accessToken = oauthService.getOAuthAccessToken(requestToken, pin); – user3661720 May 23 '14 at 13:50
  • @user3661720 I think they are a little unclear in that link I sent you. The "pin" is the same things as the "AUTHORIZATION_CODE" in the link I sent you. So the two are the same. – demongolem May 23 '14 at 14:02
  • @user3661720 Ok let me a little more explicit about what is going on in the example code. First, a temporary url is given to the user of your application in a System.out.println statement. Next, the user is expected to open a web browser and visit that temporary url which is printed out for them. Third, the user is expected to type in the PIN into your program that the temporary url displays in the browser. Then, authentication completes. – demongolem May 23 '14 at 14:15
  • Yes I tried to do. I got pin from a web-site. But this example didn` t change my "status". This code couse exception( javax.xml.bind.JAXBException): //posting status to profile client.updateCurrentStatus("LinkedIN API is cool!"); – user3661720 May 23 '14 at 14:43
  • This is exception:Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Package "com.google.code.linkedinapi.schema" is missing jaxb.properties file. Have you copied this from the generated source directory or include it in the classpath? this problem is related to the following location: at com.google.code.linkedinapi.schema.ObjectFactory – user3661720 May 23 '14 at 15:20
  • The problem, may be in it? Package "com.google.code.linkedinapi.schema" is missing jaxb.properties file – user3661720 May 23 '14 at 15:27
  • SO is not meant to be a discussion forum. The comments are too long so we cannot continue on this path. I would recommend the following course of action: 1) Ask a new question regarding your suspected properties files issue (and current state of problem.) 2) If you would like, please reward my answer by either upvote, accepted answer or both. My answer above is correct for the original problem asked about. – demongolem May 23 '14 at 17:31
  • 1
    Thank you!!!!!You helped me!!!! I solved this problem by using 1.0.429.jar if you use 1.0.416 it's missing the jaxb plugin. Jar:(https://code.google.com/p/linkedin-j/downloads/detail?name=linkedin-j-1.0.429-binary.zip&can=2&q=) And DO NOT USE Maven!!!!! – user3661720 May 23 '14 at 17:46
  • Could you help me, please? I try do to search with linkedin-j api. But i have exception: "Access to people search denied". What is a trouble? I used this example: https://code.google.com/p/linkedin-j/source/browse/trunk/linkedin-j/examples/src/main/java/com/google/code/linkedinapi/client/examples/SearchApiExample.java – user3661720 May 25 '14 at 17:49