I’m trying to get the authentication token from Monzo as in the section ‘Exchange the authorization code’ in the docs.
When I make the request using httpie from the terminal I have no problem, but when I make the request using Volley I get a 400 response.
I’ve confirmed that I’m using Volley correctly using the https://postman-echo.com/post endpoint.
Does the following use of Volley look sensible? And is there anywhere I could look to get more information on the 400 response?
VolleyLog.DEBUG = true;
val jsonBody = JSONObject()
jsonBody.put("grant_type", "authorization_code")
jsonBody.put("client_id", "oauth2client_somestring")
jsonBody.put("client_secret", "mnzpub.somestring/somestring")
jsonBody.put("redirect_uri", "http://www.sample.com")
jsonBody.put("code", code)
val request = object : JsonObjectRequest(
Method.POST, "https://api.monzo.com/oauth2/token", jsonBody,
Response.Listener<JSONObject> {
println("Got some response")
},
Response.ErrorListener {
println("That didn't work!") }) {
override fun getHeaders(): Map<String, String> {
val params = HashMap<String, String>()
params["Content-Type"] = "application/x-www-form-urlencoded; charset=utf-8"
return params
}
}