List of usage examples for twitter4j.conf ConfigurationBuilder setApplicationOnlyAuthEnabled
public ConfigurationBuilder setApplicationOnlyAuthEnabled(boolean applicationOnlyAuthEnabled)
From source file:tweetdownloader.cnr_stable.version.TwitterAuthHandler.java
/** * Is used to get permission for get the tweets. * @return/* w w w . j a va 2 s. c o m*/ */ public OAuth2Token getOAuth2Token() { OAuth2Token token = null; ConfigurationBuilder cb; cb = new ConfigurationBuilder(); cb.setApplicationOnlyAuthEnabled(true); cb.setOAuthConsumerKey(CONSUMER_KEY).setOAuthConsumerSecret(CONSUMER_SECRET); try { token = new TwitterFactory(cb.build()).getInstance().getOAuth2Token(); } catch (Exception e) { System.out.println("Could not get OAuth2 token"); e.printStackTrace(); System.exit(0); } return token; }
From source file:tweetdownloader.cnr_stable.version.TwitterAuthHandler.java
/** * This method give you the auth to work with Twitter API * @return istance of Twitter// www.jav a 2 s .c om */ public Twitter getTwitter() { OAuth2Token token; token = getOAuth2Token(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setApplicationOnlyAuthEnabled(true); cb.setOAuthConsumerKey(CONSUMER_KEY); cb.setOAuthConsumerSecret(CONSUMER_SECRET); cb.setOAuth2TokenType(token.getTokenType()); cb.setOAuth2AccessToken(token.getAccessToken()); return new TwitterFactory(cb.build()).getInstance(); }