gpt4 book ai didi

java - LinkIN API OAuth 在 ubuntu 中不工作

转载 作者:行者123 更新时间:2023-11-30 09:22:27 25 4
gpt4 key购买 nike

我正在使用 jar commons-codec-1.3 jar链接-j路标核心-1.2.1.1

用于 LinkedIn API。它在 Windows 服务器中运行良好。我在 ubuntu 中有相同的代码,但出现错误

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

我在 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

最佳答案

我终于想通了这个问题。它的发生是因为我的 ubuntu 服务器中的 date and time。在 ubuntu 中,当我更改为当前日期和时间时,它显示昨天的日期。它工作正常。

关于java - LinkIN API OAuth 在 ubuntu 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16478997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com