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 7797167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:35:53+00:00 2026-06-01T23:35:53+00:00

WHy am I get this error : java.lang.IllegalArgumentException: This consumer expects requests of type

  • 0

WHy am I get this error : java.lang.IllegalArgumentException: This consumer expects requests of type org.apache.http.HttpRequest

CommonsHttpOAuthConsumer  consumer = new CommonsHttpOAuthConsumer (CONSUMER_KEY,CONSUMER_SECRET);
            consumer.setTokenWithSecret(oaut_token, tokenSecret);

URL url = new URL(targetURL);
request = (HttpURLConnection) url.openConnection();

// sign the request
consumer.sign(request);
// send the request
request.connect();

EDIT:
Just updating the accepted answer as it is not relevant anymore. the signpost documentation is a bit outdated and suggest to use CommonsHttpOAuthConsumer in Android due to bugs on HttpURLConnection. These have been fixed and now Android removed the Apache HTTP so the correct way to deal with signpost is now via DefaultOAuthConsumer.

DefaultOAuthConsumer  consumer = new DefaultOAuthConsumer (CONSUMER_KEY,CONSUMER_SECRET);
            consumer.setTokenWithSecret(oaut_token, tokenSecret);

URL url = new URL(targetURL);
request = (HttpURLConnection) url.openConnection();

// sign the request

consumer.sign(request);
  • 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-01T23:35:56+00:00Added an answer on June 1, 2026 at 11:35 pm

    Signpost is trivial to use on android, lol, once you get past the tutorials that are not really up to date, or complete, or in particularly useful order.

    Anyway here is one way to do this using apache http instead of native android, it’s a bit ugly for the sake of brevity but should get you up and running.

    Modifed your code a bit to make it work, you probably want to make the HttpClient consistent across calls but I just inlined all that. I also notice you are deserializing the tokens so I am just going to assume that you have the actual OAuth flow working.

    Good luck!

        CommonsHttpOAuthConsumer consumer = null;
        consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY,CONSUMER_SECRET);
        consumer.setTokenWithSecret(oaut_token, tokenSecret);
    
       // Use the apache method instead - probably should make this part persistent until
       // you are done issuing API calls    
       HttpParams parameters = new BasicHttpParams();
       HttpProtocolParams.setVersion(parameters, HttpVersion.HTTP_1_1);
       HttpProtocolParams.setContentCharset(parameters, HTTP.DEFAULT_CONTENT_CHARSET);
       HttpProtocolParams.setUseExpectContinue(parameters, false);
       HttpConnectionParams.setTcpNoDelay(parameters, true);
       HttpConnectionParams.setSocketBufferSize(parameters, 8192);
    
       HttpClient httpClient = new DefaultHttpClient();
    
       SchemeRegistry schReg = new SchemeRegistry();
       schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
       ClientConnectionManager tsccm = new ThreadSafeClientConnManager(parameters, schReg);
    
       httpClient = new DefaultHttpClient(tsccm, parameters);
    
       HttpGet get = new HttpGet(targetURL); 
    
        // sign the request
        consumer.sign(get);
    
        // send the request & get the response (probably a json object, but whatever)
        String response = httpClient.execute(get, new BasicResponseHandler());
    
        // shutdown the connection manager - last bit of the apache code 
        httpClient.getConnectionManager().shutdown();
    
        //Do whatever you want with the returned info 
        JSONObject jsonObject = new JSONObject(response);
    

    That’s it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why do I get this Exception? 05-18 20:29:38.044: ERROR/AndroidRuntime(5453): java.lang.IllegalArgumentException: The key must be
I'm using dwr and spring and I get this error: java.lang.IllegalArgumentException: Javascript name *
I am not sure why I get this error: Caused by: java.lang.RuntimeException: Deferred binding
In Antlrworks I get this error: [18:21:03] Checking Grammar Grammar.g... [18:21:26] Grammar.java:12: code too
I'm using websphere and Java EE and get this error message: Exception reading propertiesfile
I'm following the Play Framework 2.0 tutorial for Java and get this error when
I am trying to put String[] in jsonObject and getting following error java.lang.IllegalArgumentException: Invalid
Why do I get compiler errors with this Java code? 1 public List<? extends
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within

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.