in src/main/java/com/epam/aidial/auth/helper/services/keycloak/MicrosoftIdentityProvider.java [23:42]
public UserInfoDto getUserInfo(String accessToken) {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(accessToken);
headers.add("Accept", "application/json");
HttpEntity<Void> requestEntity = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.exchange("https://graph.microsoft.com/v1.0/me", HttpMethod.GET, requestEntity, String.class);
JsonNode root;
try {
root = mapper.readTree(response.getBody());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
UserInfoDto userInfo = new UserInfoDto();
String photo = getUserPhoto(accessToken);
userInfo.setPicture(photo);
userInfo.setJobTitle(root.get("jobTitle").textValue());
userInfo.setEmail(root.get("mail").textValue());
userInfo.setName(root.get("displayName").textValue());
return userInfo;
}