无法使用 Volley 对 Monzo 的 API 进行身份验证

Can't authenticate with Monzo's API using Volley

我正在尝试从 Monzo 获取身份验证令牌,如 docs 中的 'Exchange the authorization code' 部分所述。 当我从终端使用 httpie 发出请求时我没有问题,但是当我使用 Volley 发出请求时我得到 400 响应。 我已经确认我使用 https://postman-echo.com/post 端点正确使用了 Volley。

下面对 Volley 的使用看起来合理吗?

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
    }
}

看来 API 不支持 application/json,在 postman 中做了一些尝试。请求的格式应为 application/x-www-form-urlencoded.