Twitter4j use getOAuthAccessToken


Hello I found v2.2.6, and was trying to do the method you login the cession of twitter but I’m not getting.

My simplified code:

public class TwitterLab {
private static Twitter twitter;

public static void main(String[] args) {
String usr = “teste”;
String pass = “test”;

 try {
     twitter = new TwitterFactory().getInstance();
         AccessToken at = twitter.getOAuthAccessToken(usr, pass);

         twitter = new TwitterFactory().getInstance(at);
     User user = twitter.verifyCredentials();
     System.out.println("Successfully verified credentials of " + user.getScreenName());
 } catch (TwitterException te) {
     System.out.println("Failed to verify credentials: " + te.getMessage());


Anyone can help me with some code, or explaining why it gives me the error:
java.lang.IllegalStateException: OAuth consumer key/secret combination not supplied


I tried posting message to twitter , hope the following details might help :
Login to , create an application and get the consumerkey,consumersecretkey,accesstoken, accesstokensecretkey

Write the following lines in the source code

ConfigurationBuilder cb = new ConfigurationBuilder();
.setOAuthConsumerKey(“Your consumer key”)
.setOAuthConsumerSecret(“Your consumer secret key”)
.setOAuthAccessToken(“Access token”)
.setOAuthAccessTokenSecret(“Yout acccess token secret”);
TwitterFactory tf = new TwitterFactory(;
Twitter twitter = tf.getInstance();


I also have a problem using twitter4j 2.2.6, similar code to above but on android system


I’ve run the code using ConfigurationBuilder class, but always get the following error:

Permission denied: connect
Relevant discussions can be found on the Internet at: or
TwitterException{exceptionCode=[b2b52c28-1206f231 b2b52c28-1206f207], statusCode=-1, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.5}

Anybody could make some suggestions?


Hi All, I went into the same problem. Did you guys solve the problems? any suggestions? thanks in advance!


Hello everyone,

I have the same problem with the others. Is there any way to overcome this problem?


Hello Team,
I am a developer using Twitter 1.1 API for automatic tweet but every time twitter is asking for login and authorize how i fixed it please please help me…
I want to tweet on twitter in background process same as and tweetlonger do.
Thanks in advance.


Hello Team ,

I am trying to use TWITTER 4j API . I have wriiten the below code :-

public final class TwitterConnection {

public static void main(String[] args) throws IOException {
 String testPost = "hello from otc";
 ConfigurationBuilder cb = new ConfigurationBuilder();

try {
TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
AccessToken accestoken = new AccessToken(“1725870422-d32GwizZYclX4KXE5vlbbvDSWJRpPnMZwcLR0MC”, “FFQgA9b1b8A0oEO9XbYBTDNUq0VbP5iuZO7gyJazAF93B”);
Status status = twitter.updateStatus(testPost);
System.out.println(“it worked!”);
if (status.getId() == 0) {
System.out .println(“Error occured while posting tweets to twitter”);
} catch (Exception e) {

Error :-

java.lang.IllegalStateException: OAuth consumer key/secret combination not supplied
at twitter4j.TwitterBaseImpl.getOAuth(
at twitter4j.TwitterBaseImpl.setOAuthAccessToken(
at com.accure.twitter.TwitterConnection.main(

Please help me for the above issue .

Thanks and Regards,
Trupti Pradhan