I'm trying to send a POST request using Kotlin in Android. I need to use Volley and I need authentication with a bearer token. I don't know how to send the bearer token together with the post request.
val queue = Volley.newRequestQueue(this)
val parameters: MutableMap<String, String> = HashMap()
parameters.put("token_name", "app");
val strReq: StringRequest = object : StringRequest(
Method.POST, "https://url.com",
Response.Listener { response ->
try {
val responseObj = JSONObject(response)
val id = responseObj.getInt("id")
val token = responseObj.getString("name")
val tipo = responseObj.getString("email")
} catch (e: Exception) { // caught while parsing the response
}
},
Response.ErrorListener { volleyError ->
})