Search in sources :

Example 1 with Authorization

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

the class AuthorizationTest method testOAuthInstance.

public void testOAuthInstance() throws Exception {
    String consumerSecret;
    String consumerKey;
    consumerSecret = p.getProperty("browser.oauth.consumerSecret");
    consumerKey = p.getProperty("browser.oauth.consumerSecret");
    Twitter twitter = new TwitterFactory().getInstance();
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    try {
        twitter.setOAuthConsumer(consumerSecret, consumerKey);
        fail("should throw IllegalStateException");
    } catch (IllegalStateException ignore) {
    }
    Authorization auth = twitter.getAuthorization();
    assertTrue(auth instanceof OAuthAuthorization);
}
Also used : Authorization(twitter4j.auth.Authorization) OAuth2Authorization(twitter4j.auth.OAuth2Authorization) OAuthAuthorization(twitter4j.auth.OAuthAuthorization) NullAuthorization(twitter4j.auth.NullAuthorization) OAuthAuthorization(twitter4j.auth.OAuthAuthorization)

Example 2 with Authorization

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

the class AuthorizationTest method testAnonymousInstance.

public void testAnonymousInstance() throws Exception {
    Twitter twitter = new TwitterFactory().getInstance();
    Authorization auth = twitter.getAuthorization();
    assertTrue(auth instanceof NullAuthorization);
}
Also used : Authorization(twitter4j.auth.Authorization) OAuth2Authorization(twitter4j.auth.OAuth2Authorization) OAuthAuthorization(twitter4j.auth.OAuthAuthorization) NullAuthorization(twitter4j.auth.NullAuthorization) NullAuthorization(twitter4j.auth.NullAuthorization)

Example 3 with Authorization

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

the class AuthorizationTest method testOAuth2Instance.

public void testOAuth2Instance() throws Exception {
    String consumerSecret = p.getProperty("browser.oauth.consumerSecret");
    String consumerKey = p.getProperty("browser.oauth.consumerSecret");
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setApplicationOnlyAuthEnabled(true);
    Twitter twitter = new TwitterFactory(cb.build()).getInstance();
    twitter.setOAuthConsumer(consumerKey, consumerSecret);
    try {
        twitter.setOAuthConsumer(consumerSecret, consumerKey);
        fail("should throw IllegalStateException");
    } catch (IllegalStateException ignore) {
    }
    Authorization auth = twitter.getAuthorization();
    assertTrue(auth instanceof OAuth2Authorization);
}
Also used : Authorization(twitter4j.auth.Authorization) OAuth2Authorization(twitter4j.auth.OAuth2Authorization) OAuthAuthorization(twitter4j.auth.OAuthAuthorization) NullAuthorization(twitter4j.auth.NullAuthorization) ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) OAuth2Authorization(twitter4j.auth.OAuth2Authorization)

Aggregations

Authorization (twitter4j.auth.Authorization)3 NullAuthorization (twitter4j.auth.NullAuthorization)3 OAuth2Authorization (twitter4j.auth.OAuth2Authorization)3 OAuthAuthorization (twitter4j.auth.OAuthAuthorization)3 ConfigurationBuilder (twitter4j.conf.ConfigurationBuilder)1