I am trying to make a POST request to a keycloak REST API endpoint with a body with application/x-www-form-urlencoded values.
Here is a cURL of a request:
curl -X POST \
https://auth.beyondtime-stage.io/auth/realms/master/protocol/openid-connect/token \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'username=admin&password=pass123&client_id=admin-cli&grant_type=password'
To my disappointment, I haven't found a way to do it with feign.
Here is one example of what I've tried:
@FeignClient(name = "beyondtime-io-kc-client", url = "${btio.keycloakUrl}", path = "/")
public interface KeycloakAdminClient {
@PostMapping(name="realms/master/protocol/openid-connect/token", consumes = "application/x-www-form-urlencoded")
String getAuthToken(@RequestParam("username") String username,
@RequestParam("password") String password,
@RequestParam("client_id") String clientId,
@RequestParam("grant_type") String grantType);
}
In my pom.xml, I am using:
spring-cloud-starter-openfeign 2.1.1.RELEASE
I've also tried adding feign-form dependency and @Param instead of @RequestParam, but no success.