如何通过 curl --user 通过 rest-assured

how to pass curl --user through rest-assured

下面是 cURL

curl --user name:passwoed -k -X POST \
  https://test_url/oauth/token \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d grant_type=client_credentials

我在下面试过但得到了 400

given().relaxedHTTPSValidation().
     auth().basic("name", "password").
when().
     post("https://test_url/oauth/token").
then().
     statusCode(200)

下面是解决方法 注意,我之前没有传递数据

 given().relaxedHTTPSValidation().
       auth().basic("name", "password").
       param("grant_type","client_credentials").
 when().
       post("https://test_url/oauth/token").
 then().
       statusCode(200);