1
votes

I've used the com.sugree.twitter technique to obtain the twitter access token and the access key. Now. I want to pass these into the twitter4j library. But, I am getting an error on this line as follows:

twitter4j.auth.AccessToken accessToken = new twitter4j.auth.AccessToken(twitter.getAccessToken(),twitter.getSecretToken());

06-21 18:43:08.140: ERROR/AndroidRuntime(1293): java.lang.IllegalStateException: Consumer key and Consumer secret not supplied.

2
It sounds like the Configuration object may not have been set up correctly, though this is usually something that would be caught when creating the Twitter instance. Do you have the code used to call the factory to get the instance? Also, are you using the Sugree's twitter-android-sdk or the thiloplanz fork? - Mark
You could check this TUT: anddev.org/advanced-tutorials-f21/sending-a-tweet-t54389.html Shows how to use Twitter4J with source files - Blundell

2 Answers

2
votes

Solution:

ConfigurationBuilder cb = new ConfigurationBuilder();
            cb.setDebugEnabled(true)
              .setOAuthConsumerKey(twitterKey)
              .setOAuthConsumerSecret(twitterSecret)
              .setOAuthAccessToken(twitter.getAccessToken())
              .setOAuthAccessTokenSecret(twitter.getSecretToken());
            TwitterFactory tf = new TwitterFactory(cb.build());
            twitter4j.Twitter t4jTwitter = tf.getInstance();
1
votes

You can specify consumer key/secret in twitter4j.properties. http://twitter4j.org/en/configuration.html