November 2018
Intermediate to advanced
388 pages
9h 5m
English
Let's write a simple REST client for getting a JWT token. We use the Jersey client to write our integration test case. This actually makes an API call and gets the response. We write the getToken() function, where we instantiate the Jersey client and invoke the API by passing the required headers, as follows:
fun getToken(): String { val client = Client.create() val webResource = client .resource("http://localhost:8080/authentication-service/authorize/jwt/token") val response = webResource .header("Accept", "application/json") .header("Content-Type", "application/json") .header("UserId", "testUser") .header("Password", "testUserPass") .post<ClientResponse>(ClientResponse::class ...
Read now
Unlock full access