oAuth 2.0
public class Autho2 {
private String Access_Token;
@BeforeMethod
public void getAccessToken() {
RestAssured.baseURI="https://test.api.amadeus.com/v1/security/oauth2/token";
JsonPath js = given().contentType(ContentType.URLENC)
.formParam("grant_type", "client_credentials")
.formParam("client_id", "3WEebG9lWQQqwnRbngz5zkhwKtmEXVKs")
.formParam("client_secret", "88uhUgeGJX31a0aa")
.when().post()
.then().extract().jsonPath();
System.out.println("access_token==>" + js.getString("access_token"));
this.Access_Token=js.getString("access_token");
}
@Test
public void oAuthTest() {
RestAssured.baseURI="https://test.api.amadeus.com/v1/shopping/flight-destinations";
/*System.out.println(Access_Token);*/
String resString = given().header("Authorization","Bearer "+Access_Token).param("origin", "PAR").param("maxPrice", 200).when().get().then().extract().asPrettyString();
System.out.println(resString);
}
}
Comments
Post a Comment