Java 应用程序在不同服务器上运行时未针对 Twitter 进行身份验证



我正在尝试在我的远程 Linux Amazon AMI 服务器上运行 Java .jar 文件。在本地,当我运行此 Java 项目时,会建立永久的 HTTP 连接,并且一切都按预期工作。但是,如果我在我的服务器上运行它,我会收到身份验证错误。我必须通过OAuth1进行身份验证才能访问Twitter的服务器,该服务器在我的本地计算机上完美运行。我是否必须在我的服务器上安装一些东西才能支持 OAuth 或类似的东西?

16214 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.DefaultHttpClient  - Authentication required
16214 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.DefaultHttpClient  - userstream.twitter.com:443 requested authentication
16214 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy  - Authentication schemes in the order of preference: [negotiate, Kerberos, NTLM, Digest, Basic]
16214 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy  - Challenge for negotiate authentication scheme not available
16215 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy  - Challenge for Kerberos authentication scheme not available
16215 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy  - Challenge for NTLM authentication scheme not available
16215 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy  - Challenge for Digest authentication scheme not available
16215 [hosebird-client-io-thread-0] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy  - Challenge for Basic authentication scheme not available
16215 [hosebird-client-io-thread-0] WARN com.twitter.hbc.httpclient.ClientBase  - hosebird-client-0 Error connecting w/ status code - 401, reason - Unauthorized

它与您的计算机时钟同步有关。 如果在日期和时间首选项上使用 MAC,请选择"自动设置日期和时间"。这为我解决了问题。

如果在 Linux 上,请按照以下安装"ntp"的链接进行操作

https://vandannguyen.wordpress.com/2014/12/02/twitter-error-connecting-w-status-code-401-reason-authorization-required/

最新更新