2013-05-10 55 views
2

工作,我現在用的罐子在 公地編解碼器1.3罐子 林肯-J 路標核-1.2.1.1林肯API OAuth是不是在Ubuntu

爲LinkedIn的API。它在Windows Server中工作正常。我在Ubuntu相同的代碼,但我對getOAuthRequestToken

Exception in thread "main" 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:180) 
    at com.cpt.linkedin.linkedINExample.authorize(linkedINExample.java:57) 
    at com.cpt.linkedin.linkedINExample.main(linkedINExample.java:38) 
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:172) 
    ... 2 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:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532) 
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1458) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1452) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1106) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) 
    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) 
    ... 4 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:1403) 
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:397) 
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) 
    at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getStatusCode(HttpURLConnectionResponseAdapter.java:22) 
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:178) 
    ... 4 more 

回答

2

我想通了這個問題終於得到了錯誤的

oAuthService=LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(key, secret); 
     request=oAuthService.getOAuthRequestToken("http://www.google.com"); 

我得到的錯誤。這是因爲我的ubuntu服務器中的date and time。在Ubuntu中,它顯示了當我更改爲當前日期和時間時的昨天的日期。它工作正常。

+0

感謝您發佈您的答案。我之前遇到過與OAuth相同的問題,並且花費了比我想要解決的時間更長的時間:) – chollida 2013-05-30 16:40:04