Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void whenLoadApplication_thenSuccess() {
- String accessToken = obtainAccessToken("7597133091274");
- System.out.println("Access Token: "+accessToken);
- }
- private String obtainAccessToken(String clientId) {
- String username = "fheras.garcia@gmail.com";
- String password = "f@r1thjhg";
- String token_url = "http://localhost:9001/tw-auth-server/oauth/token";
- String secret = "33b17e044ee6a4fa383f46ec6e28ea1d";
- final Map<String, String> params = new HashMap<String, String>();
- params.put("grant_type", "password");
- params.put("client_id", clientId);
- params.put("username", username);
- params.put("password", password);
- final Response response = RestAssured.given().auth()
- .preemptive()
- .basic(clientId, secret)
- .and().with().params(params)
- .when().post(token_url);
- return response.jsonPath().getString("access_token");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement