I use Django, when the user logs in through the API, the response that is sent to Android contains a cookie that includes CSRF and session, and I need to receive its values and send them in the header in the next request. I tried a lot, but the way I did not find a solution
private void test() {
RequestQueue requestQueue;
requestQueue = Volley.newRequestQueue(this);
String url_ = "https://xxxx.com/api/BF";
Map<String, String> params = new HashMap<>();
params.put("Email", UEmail);
params.put("Password", UPassword);
JSONObject JOParams = new JSONObject(params);
JsonObjectRequest JORequest = new JsonObjectRequest(Request.Method.POST, url_, JOParams, response -> {
try {
String status_ = response.getString("Status");
if (status_.equals("OK_")) {
Toast.makeText(this, "Login", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Login failed", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
Toast.makeText(this, "Data error", Toast.LENGTH_SHORT).show();
}
}, error -> {
Toast.makeText(this, "Connection failed", Toast.LENGTH_LONG).show();
});
requestQueue.add(JORequest);
}
}
Please complete the code. I went through all the previous answers and didn't get any results
Use the code below.