title: Twitter authentication error "Authentication credentials are missing"
body: <p>I have the following code for using the Twitter API in Java</p>
  
  <pre><code>import java.io.File;
  import java.io.PrintWriter;
  import java.util.List;
  import twitter4j.Query;
  import twitter4j.QueryResult;
  import twitter4j.Status;
  import twitter4j.Twitter;
  import twitter4j.TwitterFactory;
  import twitter4j.conf.ConfigurationBuilder;
  
  public class TwitterDataCollector {
  
      public static void main(String[] args) throws Exception {
  
          ConfigurationBuilder cb = new ConfigurationBuilder();
  
          cb.setDebugEnabled(true)
            .setOAuthConsumerKey(comsumerKey)
            .setOAuthConsumerSecret(consumerSecret)
            .setOAuthAccessToken(accesstoken)
            .setOAuthAccessTokenSecret(accesstokensecret);
  
          TwitterFactory tf = new TwitterFactory(cb.build());
          Twitter twitter = tf.getInstance();
  
          //PrintWriter tweetWriter = null;
           twitter = TwitterFactory.getSingleton();
          List&lt;Status&gt; statuses = twitter.getHomeTimeline();
          System.out.println("Showing home timeline.");
  
          for (Status status : statuses) {
              System.out.println(status.getUser().getName() + ":" + status.getText());
          }
      }
  }
  </code></pre>
  
  <p>I am trying to authenticate to the Twitter API with consumer key and access token and trying to access my timeline but it is showing</p>
  
  <pre><code>Exception in thread "main" 
  java.lang.IllegalStateException: Authentication credentials are missing. See http://twitter4j.org/en/configuration.html for details
  at twitter4j.TwitterBaseImpl.ensureAuthorizationEnabled(TwitterBaseImpl.java:186)
  at twitter4j.TwitterImpl.get(TwitterImpl.java:1554)
  at twitter4j.TwitterImpl.getHomeTimeline(TwitterImpl.java:105)
  at TwitterDataCollector.main(TwitterDataCollector.java:24)
  </code></pre>