在 Play 框架中获取 OAuth2 Scalatest 时为 400

400 when getting OAuth2 Scalatest in Play framework

我正在尝试在 play framework scalatest 中获取 OAuth2 不记名令牌。 但是,服务器似乎无法理解我在 FakeRequest() 中发送的 json。 fakerequest是这样的

val req = FakeRequest().withBody(
Json.obj(
"grant_type" -> "client_credentials",
"client_credentials" -> clientID,
"client_secret" -> clientSecret,
"scope" -> "all"
))

它说

{"error":"invalid_request","error_description":"required parameter: grant_type"}

你知道为什么它不起作用吗? 它大摇大摆地工作得很好。

尝试在 FakeRequest 对象中将请求方法指定为 POST。 FakeRequest 可能默认做 GET,因此无法找到请求参数。