Scribe OAuthException 在 ServiceBuilder.build() 之后没有为 Service.getRequestToken() 返回响应
我正在尝试获取授权 url,以允许我的用户授权我的应用程序进行 twitter api 调用。
我已经在 Twitter 上注册了该应用程序并获得了消费者密钥和秘密。
scribe-1.1.3.jar 和 commons-code-1.5.jar 位于类路径中。
我在代理后面运行并添加了 System.setProperty("java.net.useSystemProxies", "true");
代码如下:
ServiceBuilder lBuilder = new ServiceBuilder();
lBuilder.provider(TwitterApi.class);
lBuilder.apiKey("----");
lBuilder.apiSecret("----");
OAuthService lService = lBuilder.build();
Token lAccessToken = lService.getRequestToken();
最后一行抛出异常:
org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: 'Failed to validate oauth signature and token'
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
看起来 Twitter 响应为空或丢失。
另外,我正在使用基于 servlet 的应用程序,并且您的所有示例都从 System.in 检索响应。
我可以通过 scribe API 捕获传入的响应吗?
谢谢。
I am trying to get the authorization url to allow my users to authorize my app for twitter api calls.
I have registered the app at Twitter and gotten the Consumer Key and Secret.
scribe-1.1.3.jar and commons-code-1.5.jar are in the Classpath.
I am running behind a proxy and added System.setProperty("java.net.useSystemProxies", "true");
The code follows:
ServiceBuilder lBuilder = new ServiceBuilder();
lBuilder.provider(TwitterApi.class);
lBuilder.apiKey("----");
lBuilder.apiSecret("----");
OAuthService lService = lBuilder.build();
Token lAccessToken = lService.getRequestToken();
The last line throws exception:
org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: 'Failed to validate oauth signature and token'
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
It looks like the Twitter response is empty or missing.
Also, I am using a servlet based App and all of your examples are retrieving responses from System.in.
Can I capture the incoming responses through the scribe API?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论