Example usage for twitter4j.auth OAuth2Token getAccessToken

List of usage examples for twitter4j.auth OAuth2Token getAccessToken

Introduction

In this page you can find the example usage for twitter4j.auth OAuth2Token getAccessToken.

Prototype

public String getAccessToken() 

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
 *///w w w  .  j a  va2s.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;

    token = getOAuth2Token();/*from ww  w.  j  a  va2s  .c o  m*/
    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 w  w .  ja v  a 2s.c om
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;
    token = getOAuth2Token();/*w ww  .  j  a v a 2s .c o m*/
    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//  w w w . java 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();
}