Hey everyone,

I'm developing an Android app which needs to perform an HTTPPost to
get a token back. Then use that token for subsequent calls.  When I
perform the initial call to get the token, it throws an exception:

    org.apache.http.auth.MalformedChallengeException: Authentication
challenge is empty

Here is my code:

    DefaultHttpClient httpclient = new DefaultHttpClient();
    httpclient.getCredentialsProvider().setCredentials(new
AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new
UsernamePasswordCredentials("username", "password"));

    HttpPost httppost = new HttpPost(authenticationURL);
    httppost.addHeader("app_key", app_key);

    String strResponse = "";
    try {
     HttpResponse response = httpclient.execute(httppost);  <---
exception thrown here
     HttpEntity entity = response.getEntity();

     if (entity != null) {
          InputStream instream = entity.getContent();
          strResponse = convertStreamToString(instream);
          instream.close();
     }

     JSONObject jObject=new JSONObject(strResponse);
     wrapAccessToken = jObject.getString("wrap_access_token");
     } catch (ClientProtocolException e) {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     } catch (JSONException e) {
       e.printStackTrace();
     }

I googled "Authentication challenge is empty", and one this website:
http://fmpwizard-scala.posterous.com/using-apache-httpclient-authentication-in-sca
he had a similar problem.  He determined that his web server requires
preemptive authentication.  Which I believe ours does too.  I tried
implementing what he did, and still, no dice.

I've hard coded the token in other requests, and I am able to perform
HTTPGet calls.

What am I doing wrong?   What is the Authentication Challenge that I'm
missing?

Thanks in advance

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to