Example usage for twitter4j.conf ConfigurationBuilder setOAuth2AccessToken

List of usage examples for twitter4j.conf ConfigurationBuilder setOAuth2AccessToken

Introduction

In this page you can find the example usage for twitter4j.conf ConfigurationBuilder setOAuth2AccessToken.

Prototype

public ConfigurationBuilder setOAuth2AccessToken(String oAuth2AccessToken) 

Source Link

Usage

From source file:Beans.Crawler.java

/**
 * Get a fully application-authenticated Twitter object useful for making subsequent calls.
 *
 * @return   Twitter4J Twitter object that's ready for API calls
 *///  ww  w.j a v a2  s  . c  o  m
public static Twitter getTwitter() {
    OAuth2Token token;

    //   First step, get a "bearer" token that can be used for our requests
    token = getOAuth2Token();

    //   Now, configure our new Twitter object to use application authentication and provide it with
    //   our CONSUMER key and secret and the bearer token we got back from Twitter
    ConfigurationBuilder cb = new ConfigurationBuilder();

    cb.setApplicationOnlyAuthEnabled(true);

    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);

    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());

    //   And create the Twitter object!
    return new TwitterFactory(cb.build()).getInstance();

}

From source file:br.com.controller.TweetController.java

public static Twitter getTwitter() {
    OAuth2Token token;//from   w  ww  . j  ava  2s.  co m

    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();
}

From source file:com.data.dataanalytics.twitter.TwitterFeed.java

/**
 * Get a fully application-authenticated Twitter object useful for making subsequent calls.
 *
 *//*from   w  ww.  j  a  v  a2s .  c  o  m*/
protected static twitter4j.Twitter getTwitter() {
    OAuth2Token token;

    //   First step, get a "bearer" token that can be used for our requests
    token = getOAuth2Token();

    //   Now, configure our new Twitter object to use application authentication and provide it with
    //   our CONSUMER key and secret and the bearer token we got back from Twitter
    ConfigurationBuilder cb = new ConfigurationBuilder();

    cb.setApplicationOnlyAuthEnabled(true);

    cb.setOAuthConsumerKey(CONSUMER_KEY);
    cb.setOAuthConsumerSecret(CONSUMER_SECRET);

    cb.setOAuth2TokenType(token.getTokenType());
    cb.setOAuth2AccessToken(token.getAccessToken());

    //   Create the Twitter object
    return new TwitterFactory(cb.build()).getInstance();

}

From source file:ontoSentiment.Util.java

public static Twitter getTwitter() {
    OAuth2Token token;/*  www.j  av a  2 s  .  c  o  m*/
    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();
}

From source file:tweetdownloader.cnr_stable.version.TwitterAuthHandler.java

/**
 * This method give you the auth to work with Twitter API
 * @return istance of Twitter//from   w w w .j a  v a2  s.  c o m
 */
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();
}