Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:32:01+00:00 2026-06-08T08:32:01+00:00

Trying to integrate my webapp with Twitter using twitter4j lib. I have registered my

  • 0

Trying to integrate my webapp with Twitter using twitter4j lib.
I have registered my app on twitter site and got Consumer key and Consumer secret values.
Nothing special,standard OAuth step.

code:

public class TwitterService {
    private final String CONSUMER_KEY = "xxx";
    private final String CONSUMER_SECRET = "yyy";

    public String fav() {
        Twitter twitter = TwitterFactory.getSingleton();
        twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
...

exception:

Caused by: java.lang.IllegalStateException: consumer key/secret pair already set.

I have no more configuration for key and secret,any .properties or other file.

EDIT:

commenting line twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET); causes exception:

java.lang.IllegalStateException: OAuth consumer key/secret combination not supplied
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:32:03+00:00Added an answer on June 8, 2026 at 8:32 am

    Looking at both the code and documentation, it looks like your method of instantiating a Twitter instance is not recommended. If you want to supply configuration programmatically (and not use properties), it looks like you need to supply a Configuration to the TwitterFactory.

    ...
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.setOAuthConsumerKey(CONSUMER_KEY);
    builder.setOAuthConsumerSecret(CONSUMER_SECRET);
    Configuration configuration = builder.build();
    TwitterFactory factory = new TwitterFactory(configuration);
    Twitter twitter = factory.getInstance();
    ...
    

    The singleton provided by a factory that hasn’t been supplied with a configuration defaults to using an Authorization implementation backed by a PropertyConfiguration configuration. If there is no properties file, it looks like it shouldn’t instantiate an OAuthAuthorization auth, which is what would cause the exception you’re seeing. But PropertyConfiguration does search the entire CLASSPATH for an appropriate properties file, so maybe you overlooked one. You could try logging the key and secret right after getting the Twitter instance to see what they are set to:

    System.out.println("key:" + twitter.getConfiguration().getOAuthConsumerKey());
    System.out.println("secret: " + twitter.getConfiguration().getOAuthConsumerSecret());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate a Facebook send button into my site using Facebook app.
I have created a webapp using backbone.js and I am trying to integrate google
I'm trying to integrate some Google maps bits into my Java web app using
Am trying to integrate Apple Push Notification in my app. I have studied the
I am trying to integrate a d3 script into gwt web-app. However I cannot
I'm trying to integrate passport into my nodejs server using connect, but can't seem
Hi I'm trying to integrate MySpace with my Android app. As I'm new to
I am trying to integrate a simple login for my site with php. i
Hi I'm trying to integrate an LDAP search functionality into my app similar to
I'm trying to integrate bean validation using hibernate validator to my web application :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.