title: Twitter authentication credentials
body: <p>I am new to the social network analysis and twitter API.I wanted to collect tweets on certain topic .So i have written the following code</p>
  
  <pre><code>package com;
  
  import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.List;
  
  import twitter4j.Query;
  import twitter4j.QueryResult;
  import twitter4j.Status;
  import twitter4j.Tweet;
  import twitter4j.Twitter;
  import twitter4j.TwitterException;
  import twitter4j.TwitterFactory;
  
  public class TwitterSearchAdvance {
      public static void main(String[] vishal) throws TwitterException,
              IOException {
          // List&lt;Tweet&gt; Data = new ArrayList&lt;Tweet&gt;();
          StringBuffer stringbuffer = new StringBuffer();
          Twitter twitter = new TwitterFactory().getInstance();
  
          for (int page = 0; page &lt;= 4; page++) {
              Query query = new Query("Airtel");
              // query.setRpp(100); // 100 results per page
  
              QueryResult qr = twitter.search(query);
              List&lt;Status&gt; qrTweets = qr.getTweets();
              System.out.println("-------------------" + qrTweets.size());
              // break out if there are no more tweets
  
              for (Status t : qrTweets) {
                  System.out.println(t.getCreatedAt() + ": " + t.getText());
  
                  stringbuffer.append(t);
                  stringbuffer.append("\n");
                  BufferedWriter bw = new BufferedWriter(new FileWriter(new File(
                          "/home/vishal/FirstDocu.txt"), true));
                  bw.write(stringbuffer.toString());
                  bw.newLine();
                  // bw.write(t.getCreatedAt() + ": " + t.getText());
                  bw.close();
  
              }
          }
      }
  }
  </code></pre>
  
  <p>But when i run the following program the following error starts coming</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalStateException: Authentication credentials are missing. See http://twitter4j.org/configuration.html for the detail.
      at twitter4j.TwitterBaseImpl.ensureAuthorizationEnabled(TwitterBaseImpl.java:200)
      at twitter4j.TwitterImpl.get(TwitterImpl.java:1833)
      at twitter4j.TwitterImpl.search(TwitterImpl.java:282)
      at com.TwitterSearchAdvance.main(TwitterSearchAdvance.java:28)
  </code></pre>
  
  <p>Where do i need to provide credentials in my program</p>
  
  <p>Thanks</p>