Twitter4J - 401:Authentication credentials were missing or incorrect [closed]
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this questionI'm playing around with the Twitter4J API and am getting the 401:Authentication credentials were missing or incorrect when using the createFriendship
method.
I obtain an instance of Twitter as follows:
protected Twitter getApi(String consumerKey, Str开发者_开发知识库ing consumerSecret, String accessToken, String secret) {
AccessToken token = new AccessToken(accessToken, secret);
return new TwitterFactory().getOAuthAuthorizedInstance(consumerKey, consumerSecret, token);
}
Once obtained I can successfully use the updateStatus method to tweet something. However when I try to execute the createFriendship method I get the following error even though the status updates are working fine
Request processing failed; nested exception is 401:Authentication credentials were missing or incorrect. {"request":"\/1\/friendships\/create.json?screen_name=[user]","error":"Incorrect signature"} TwitterException{exceptionCode=[564a75a9-01c7e75c], statusCode=401, retryAfter=0, rateLimitStatus=null, version=2.1.5}
In the above error the screen_name=[user] the [user] section is replaced with the correct Twitter screen name.
Is there something I am missing?
Thank you
Sorry it was a simple problem with 2 different versions of Twitter4J on the classpath!
精彩评论