Hi I am trying to implement "status update" via twitter4j library.
However it am always getting the same error:
401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect.
Ensure that you have set valid consumer key/secret, access token/secret, and the system clock in in sync.
TwitterException{exceptionCode=[6b80c41c-1bd1da85], statusCode=401, retryAfter=-1, rateLimitStatus=null, featureSpecificRateLimitStatus=null, version=2.2.5-SNAPSHOT(build: 5f9c44cd0e0c1972f8d17653a226b9b6a3392ac2)} ...
Below you can find the code piece:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey(cons_key)
.setOAuthConsumerSecret(cons_secret)
.setOAuthAccessToken(acc_token)
.setOAuthAccessTokenSecret(acc_secret);
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
twitter4j.Status status;
try {
status = twitter.updateStatus(params[0]);
if (status.getId() == 0) {
System.out.println("Error occured while posting tweets to twitter");
}
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
I am pretty sure about I have the valid consumer/access tokens/secrets.
I don't know how to sync the system clock.
Do you have an idea what is the actual problem behind this error? I couldn't find any useful answer on internet.
Any help would be appreciated.. Thanks in advance!
You can try few things -
Also use latest version of twitter4j.