Java 在使用OAuth的路标进行身份验证时,不会检索请求令牌
例外情况:Java 在使用OAuth的路标进行身份验证时,不会检索请求令牌,java,api,oauth,tumblr,oauth-provider,Java,Api,Oauth,Tumblr,Oauth Provider,例外情况: public class Tumblr { public static void main(String args[]) throws OAuthCommunicationException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthNotAuthorizedException { OAuthConsumer consumer = new Defa
public class Tumblr {
public static void main(String args[]) throws OAuthCommunicationException, OAuthMessageSignerException, OAuthExpectationFailedException, OAuthNotAuthorizedException
{
OAuthConsumer consumer = new DefaultOAuthConsumer("ConsumerKey",
"ConsumerSecret");
OAuthProvider provider = new DefaultOAuthProvider(
"http://www.tumblr.com/oauth/request_token", "http://www.tumblr.com/oauth/access_token",
"http://www.tumblr.com/oauth/authorize");
String CallbackURL="http://localhost:8084/FinalTumblr/index.jsp";
String authUrl = provider.retrieveRequestToken(consumer,CallbackURL);
// String authUrl[] = provider.retrieveRequestToken(OAuth.OUT_OF_BAND);
System.out.println("AuthUrl.."+authUrl);
System.out.println("Request token: " + consumer.getToken());
System.out.println("Token secret: " + consumer.getTokenSecret());
// create an HTTP request to a protected resource
}
}
知道发生此错误的原因吗?得到相同的错误。你有什么解决方案吗?问题解决了,如果测试设备不能正常工作,需要在emulator中测试。可能是因为错误的日期/时间或没有sim卡。得到相同的错误。你有什么解决方案吗?问题解决了,如果测试设备无法正常工作,则需要在emulator中进行测试。原因可能是日期/时间错误或没有sim卡。
"Exception in thread "main" oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Service provider responded in error: 400 (Bad Request)
at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:218)
at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:74)
at Tumblr.main(Tumblr.java:42)
Caused by: oauth.signpost.exception.OAuthCommunicationException: Service provider responded in error: 400 (Bad Request)
at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:245)
at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:193)
... 2 more
Java Result: 1"