Java 如何在Rest assured中传递头中的授权令牌?

Java 如何在Rest assured中传递头中的授权令牌?,java,rest,authentication,rest-assured,Java,Rest,Authentication,Rest Assured,尝试使用Rest-assured自动化api测试 @Test public void Login() { Response resp = given(). body("{\"phone_number\":\"2222222222\",\"\r\n" + " + \" \"country_code\": \"+91\",\"\r\n" + "

尝试使用Rest-assured自动化api测试

@Test
public void Login() {
    Response resp = given().
            body("{\"phone_number\":\"2222222222\",\"\r\n" + 
                    "               + \" \"country_code\": \"+91\",\"\r\n" + 
                    "               + \" \"login_type\": 0}").
            when().
            contentType(ContentType.JSON).
            post("http://url/api/v1/login");

    System.out.println(resp.asString());
}

添加授权标头

Response resp = given().header("Authorization", "Bearer "+token).body(...
有关详细信息,请参阅