use of com.androidquery.auth.BasicHandle in project androidquery by androidquery.
the class AQueryAsyncTest method testAjaxPostMultiAuth.
public void testAjaxPostMultiAuth() {
String url = "http://www.androidquery.com/p/multipart";
BasicHandle handle = new BasicHandle("username", "1234");
Map<String, Object> params = new HashMap<String, Object>();
byte[] data = new byte[1234];
byte[] data2 = new byte[2345];
params.put("data", data);
params.put("data2", data2);
aq.auth(handle).ajax(url, params, JSONObject.class, new AjaxCallback<JSONObject>() {
@Override
public void callback(String url, JSONObject jo, AjaxStatus status) {
AQUtility.debug(status.getCode(), status.getError());
AQueryAsyncTest.this.result = jo;
}
});
waitAsync();
JSONObject jo = (JSONObject) result;
AQUtility.debug(jo);
assertNotNull(jo);
assertEquals(1234, jo.optInt("data"));
assertEquals(2345, jo.optInt("data2"));
JSONObject headers = jo.optJSONObject("headers");
assertNotNull(headers.optString("Authorization"));
}
use of com.androidquery.auth.BasicHandle in project androidquery by androidquery.
the class AjaxAuthActivity method auth_basic.
public void auth_basic() {
BasicHandle handle = new BasicHandle("tinyeeliu@gmail.com", "password");
String url = "http://xpenser.com/api/v1.0/reports/";
aq.auth(handle).progress(R.id.progress).ajax(url, JSONArray.class, this, "basicCb");
}
use of com.androidquery.auth.BasicHandle in project androidquery by androidquery.
the class AQueryAuthTest method testBasicAuthHandle.
/*
public void testBasicAuth() {
//BasicHandle handle = new BasicHandle("tinyeeliu@gmail.com", "password");
String url = "http://xpenser.com/api/v1.0/reports/";
AjaxCallback<JSONArray> cb = new AjaxCallback<JSONArray>();
String cred = "tinyeeliu@gmail.com:password";
String auth = "Basic " + Base64.encodeToString(cred.getBytes(), Base64.DEFAULT);
AQUtility.debug("auth", auth);
cb.header("Authorization", auth);
cb.header("Host", "xpenser.com");
//cb.header("User-Agent", MOBILE_AGENT);
cb.url(url).type(JSONArray.class).weakHandler(this, "basicCb").async(getActivity());
waitAsync();
JSONArray jo = (JSONArray) result;
AQUtility.debug(jo);
assertNotNull(jo);
}
*/
public void testBasicAuthHandle() {
BasicHandle handle = new BasicHandle("tinyeeliu@gmail.com", "password");
String url = "http://xpenser.com/api/v1.0/reports/";
aq.auth(handle).ajax(url, JSONArray.class, this, "basicCb");
waitAsync();
JSONArray jo = (JSONArray) result;
AQUtility.debug(jo);
assertNotNull(jo);
}
Aggregations