Vote count:
0
I'm having a little trouble to fetch information from our REST API.
I'm using this android library http://ift.tt/MlefdP in its last version 1.4.6, I'm actually following the same steps from the tutorial, but the console always returns me that basic authentication challenge is expected. The API SERVER asks only for username and password but the security method is digest. Whenever I make a call to the server via the getPublicTimeline in the debug console it shows "Authentication error: basic authorization challenge expected, but not found", but I cannot find in the documentation how to do this.
Any idea anyone
Here's my Communication class
public class CommManager {
private static final String BASE_URL = "http://ift.tt/1mTEk1x";
public static int timeOut = 15 * 1000;
private static AsyncHttpClient client = new AsyncHttpClient();
public static void get(String url, RequestParams params, AsyncHttpResponseHandler handler){
client.setTimeout(timeOut);
client.setBasicAuth("xxxx","yyyyyyyyyyyy");
client.get(getAbsoluteUrl(url), params, handler);
}
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
AsyncHttpClient client = new AsyncHttpClient();
client.post(getAbsoluteUrl(url), params, responseHandler);
}
private static String getAbsoluteUrl(String relativeUrl) {
return BASE_URL + relativeUrl;
}
}
This is the method in my activity
public void getPublicTimeline(String query) throws JSONException {
CommManager.get("module/method/" + query, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONArray timeline) {
// Pull out the first event on the public timeline
try {
JSONObject firstEvent = (JSONObject) timeline.get(0);
String tweetText = firstEvent.getString("text");
// Do something with the response
System.out.println(tweetText);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
asked 19 secs ago
Can't acess REST API with digest auth
Aucun commentaire:
Enregistrer un commentaire