alfdev / linkedin-j

Automatically exported from code.google.com/p/linkedin-j
0 stars 0 forks source link

oauthService.getOAuthRequestToken(callbackUrl) throws an exception-HTTP 400 Bad Request #42

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Trying to generate the OAuth request token throws an exception on the Apache 
Tomcat Server.
The following code works fine on the desktop in a NetBeans 6.7 project and it 
also worked previously on Apache Tomcat web application using servlets built by 
Netbeans 6.7. However, its stopped working on the server now

/***********************************************************************/
Code which throws the exception
/***********************************************************************/

private static String generateLinkedInUrl(){
    try{
    final LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(LINKEDIN_CONSUMER_KEY,LINKEDIN_CONSUMER_SECRET);
    String callbackUrl="http://addison.cyberonix.net/CatServer/LinkedInServlet";
    LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken(callbackUrl);
    String url=requestToken.getAuthorizationUrl();
    //session.setAttribute("LINKEDIN_REQUEST_TOKEN", requestToken);
    System.out.println(url);
    return url;
    }
    catch(Exception ex){
        ex.printStackTrace(System.out);
    }
    return null;
    }

}

/***********************************************************************/
What is the expected output? What do you see instead?
/***********************************************************************/

The result should be a valid request token url, like the following generated on 
a Netbeans 6.7 desktop version of the application
https://www.linkedin.com/uas/oauth/authorize?oauth_token=e749f6a5-1538-4b38-a282
-ec81d1b58e9f
/***********************************************************************/
Instead there is the following exception
/***********************************************************************/

com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: 
oauth.signpost.exception.OAuthCommunicationException: Communication with the 
service provider failed: Server returned HTTP response code: 400 for URL: 
https://api.linkedin.com/uas/oauth/requestToken
    at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:161)
    at RegistrationDatabase.SNWSelectorServlet.generateLinkedInUrl(SNWSelectorServlet.java:281)
    at RegistrationDatabase.SNWSelectorServlet.processRequest(SNWSelectorServlet.java:158)
    at RegistrationDatabase.SNWSelectorServlet.doGet(SNWSelectorServlet.java:205)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
Caused by: oauth.signpost.exception.OAuthCommunicationException: Communication 
with the service provider failed: Server returned HTTP response code: 400 for 
URL: https://api.linkedin.com/uas/oauth/requestToken
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
    at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
    at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:153)
    ... 17 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for 
URL: https://api.linkedin.com/uas/oauth/requestToken
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1368)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1362)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1016)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
    at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getContent(HttpURLConnectionResponseAdapter.java:18)
    at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:228)
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189)
    ... 19 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for 
URL: https://api.linkedin.com/uas/oauth/requestToken
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
    at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getStatusCode(HttpURLConnectionResponseAdapter.java:22)
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:178)
    ... 19 more
/***********************************************************************/

What version of the product are you using? On what operating system?
linkedin-j-0.1-rc4
Windows works ok
Apache Tomcat on Linux throws the exception

Please provide any additional information below.

Original issue reported on code.google.com by srk1...@gmail.com on 4 Aug 2010 at 7:41

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
How to get the URL automatic when i get the 
https://www.linkedin.com/uas/oauth/authorize?oauth_token=75--9550a565-fe67-47fc-
bc86-29b3af9f5a54 

Original comment by vipinvar...@gmail.com on 25 Mar 2015 at 7:06