i'm newbie with micronaut and can't get value in a body request.
I'm using "x-www-form-urlencoded", and i need get some values for use on authentication.
Controller:
@Controller
@Secured(SecurityRule.IS_AUTHENTICATED)
public class ControllerApi {
@Post("/hello")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public String helloPost(){
return "POST hello ";
}
}
AuthenticationProviderForm:
@Singleton
public class AuthenticationProviderForm implements AuthenticationProvider {
@Override
public Publisher<AuthenticationResponse> authenticate(@Nullable HttpRequest<?> httpRequest,
AuthenticationRequest<?, ?> authenticationRequest) {
httpRequest.getBody(); //This return is "empty", and i need the values here.
}
}
Request:
curl --location --request POST 'http://localhost:8080/hello' \
--header 'Origin: localhost' \
--header 'Authorization: Basic YWxhbjEyMzpjYWp1MTIz' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=TESTE' \
--data-urlencode 'client_id=alan123' \
--data-urlencode 'client_secret=caju123'
Thanks !