}
private void refresh() throws IOException, InterruptedException, AuthenticationException {
Object payload = new RefreshPayload(accessToken, clientToken);
HttpRequest request = HttpRequest
.post(REFRESH_URL)
.bodyJson(payload)
.execute();
if (request.getResponseCode() != 200) {
ErrorResponse error = request.returnContent().asJson(ErrorResponse.class);
throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
} else {
AuthenticateResponse response =
request.returnContent().asJson(AuthenticateResponse.class);
accessToken = response.getAccessToken();
clientToken = response.getClientToken();
identities = response.getAvailableProfiles();
for (Identity identity : identities) {
identity.setAccessToken(accessToken);