views:

124

answers:

1

Hi;

I am using twitter4j-core-2.1.2.jar.

Following is my code which executed after callback url hit.

Code

    String token = (String) session.getAttribute("token");
String tokenSecret = (String)session.getAttribute("tokenSecret");

AccessToken accessToken =   new AccessToken(token, tokenSecret);

Twitter twitter = new
TwitterFactory().getOAuthAuthorizedInstance(CONSUMER_KEY,CONSUMER_SECRET,accessToken);

// getting exception on this line.

User user = twitter.verifyCredentials(); 

Follwowing is the exception

java.lang.IncompatibleClassChangeError: Found interface twitter4j.User, but class was expected at com.thefollowfriday.servlet.HomeServlet.doGet(HomeServlet.java:62) at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) Reason: TwitterException{statusCode=401, retryAfter=0, rateLimitStatus=null} at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java: 301) at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java: 68) at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java: 90) at twitter4j.Twitter.verifyCredentials(Twitter.java:1134) at com.thefollowfriday.servlet.HomeServlet.doGet(HomeServlet.java:68) at javax.servlet.http.HttpServlet.service(HttpServlet.java:693) at javax.servlet.http.HttpServlet.service(HttpServlet.java:806) at

Please help. I am stuck on it.

A: 

Status code 401 typically indicates a problem with credentials on the Twitter server, in this case while the server is trying to verify the user using the supplied credentials. Are you sure all the values you're passing are valid values (token or tokenSecret aren't null perhaps)?