I'm trying to port the following curl shell in a RestAssured Test:
curl -X POST http://localhost:8180/auth/realms/demo/protocol/openid-connect/token \
--user backend-service:secret \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'username=alice&password=alice&grant_type=password'
Here is my RestAssured version:
response = given().urlEncodingEnabled(true)
.auth().basic("backend-service", "secret")
.param("grant_type", "password")
.param("client_id", "backend-service")
.param("username", "alice")
.param("password", "alice")
.header("Accept", ContentType.JSON.getAcceptHeader())
.post("http://localhost:8180/auth/realms/demo/protocol/openid-connect/token")
.then().statusCode(200).extract()
.response();
Unfortunately, the problem is the "--user" parameter, which is not translated through the auth().basic(). From the server log I can see it's the only parameter that it's null:
type=LOGIN_ERROR, realmId=demo, clientId=backend-service, userId=null, ipAddress=127.0.0.1, error=invalid_client_credentials, grant_type=password
Any idea how to configure it ? Thanks