I am trying to use volley with oauth1 inside my project. but I don't know how to implement/use fileds like "Consumer Secret", "Token Secret" signature and "Nounce" inside the header like the picture shown below.
Current code for json Request
RequestQueue queue = VolleyUtils.getRequestQueue();
try {
JSONObject jsonObject = ESRequest.jsonObject;
ESJsonRequest myReq = new ESJsonRequest(
ESRequest.method,
ESRequest.mReqUrl,
jsonObject,
createReqSuccessListener(ESRequest),
createReqErrorListener(ESRequest)) {
protected Map<String, String> getParams() throws AuthFailureError {
Long tsLong = System.currentTimeMillis()/1000;
String ts = tsLong.toString();
// try {
// Mac mac = Mac.getInstance("HmacSHA1");
//
// }catch (NoSuchAlgorithmException ex){
// ex.printStackTrace();
// }
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/json");
params.put("oauth_consumer_key","4e77abaec9b6fcda9b11e89a9744c2e1");
params.put("oauth_token","2da943934104293b167fe2feaffca9a1");
params.put("oauth_signature_method","HMAC-SHA1");
params.put("oauth_timestamp",ts);
params.put("oauth_version","1.0");
// params.put("Consumer Secret","94efe40eb55a8d6f1d9d88696de0d37f");
// params.put("Token Secret","b89be3cfb341f87bfd7fdf7c06f3c4e0");
return params;
}
};
myReq.setRetryPolicy(new DefaultRetryPolicy(
DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 4,
BABTAIN_MAX_RETRIES,
BABTAIN_BACKOFF_MULT));
myReq.setHeader("Cache-Control", "no-cache");
//myReq.setHeader("Content-Type", "application/json");
queue.add(myReq);
} catch (Exception e) {
e.printStackTrace();
}
Problem
I google a lot and build this code. but it's not completed. Don't know how to add the filed "Nonce" , "Consumer Secret", "Token Secret" into this code.
is this the right way to do so? if it's not how to implement oauth1 header with above details..
? How to get a header like PostMan generated below using these details with volley
OAuth oauth_consumer_key="4e77abaec9b6fcda9b11e89a9744c2e1",oauth_token="2da943934104293b167f6klfeaffca9a1",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1480672395",oauth_nonce="5KEfWK",oauth_version="1.0",oauth_signature="nnbiava6yCkbSo1RDmtN%FmIoN4c%3D"
please help.. Thank you
Edit
PostMan Response with Header