FakeRequest withFormUrlEncodedBody data is lost

You mean Authenticated right? Because isAuthenticatedAsync is already there.

Authenticated method resides in play.api.mvc.Security object

Just to emphasize, It works as expected using the real request (using the browser) and I can get the body data.

But with FakeRequest() I’m not able to get any body data because its empty

I think the problem could be related with Authenticated method that takes RequestHeader, and then It is converted(?) to the Request type my main action expects.

I tried to trace the flow of code execution but I couldn’t understand why what is happening

  def Authenticated[A](
    userinfo: RequestHeader => Option[A],
    onUnauthorized: RequestHeader => Result
  )(action: A => EssentialAction): EssentialAction = {

    EssentialAction { request =>
      userinfo(request).map { user =>
        action(user)(request)
      }.getOrElse {
        Accumulator.done(onUnauthorized(request))
      }
    }

  }