Search in sources :

Example 6 with OAuthAuthorization

use of twitter4j.auth.OAuthAuthorization in project twitter4j by yusuke.

the class AsyncTwitterFactory method getInstance.

/**
 * Returns a OAuth Authenticated instance.<br>
 * consumer key and consumer Secret must be provided by twitter4j.properties, or system properties.<br>
 * Unlike {@link AsyncTwitter#setOAuthAccessToken(twitter4j.auth.AccessToken)}, this factory method potentially returns a cached instance.
 *
 * @param accessToken access token
 * @return an instance
 */
public AsyncTwitter getInstance(AccessToken accessToken) {
    String consumerKey = conf.getOAuthConsumerKey();
    String consumerSecret = conf.getOAuthConsumerSecret();
    if (null == consumerKey && null == consumerSecret) {
        throw new IllegalStateException("Consumer key and Consumer secret not supplied.");
    }
    OAuthAuthorization oauth = new OAuthAuthorization(conf);
    oauth.setOAuthConsumer(consumerKey, consumerSecret);
    oauth.setOAuthAccessToken(accessToken);
    return new AsyncTwitterImpl(conf, oauth);
}
Also used : OAuthAuthorization(twitter4j.auth.OAuthAuthorization)

Aggregations

OAuthAuthorization (twitter4j.auth.OAuthAuthorization)6 Test (org.junit.jupiter.api.Test)1 LoadTwitterFunction (org.talend.spark.function.LoadTwitterFunction)1 Status (twitter4j.Status)1 AccessToken (twitter4j.auth.AccessToken)1 Authorization (twitter4j.auth.Authorization)1 NullAuthorization (twitter4j.auth.NullAuthorization)1 OAuth2Authorization (twitter4j.auth.OAuth2Authorization)1 ConfigurationBuilder (twitter4j.conf.ConfigurationBuilder)1