I have a traditional Oauth2 setup for my micro services. When i try to use
CustomUserDetails principal = (CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
It always gives me ClassCastException string can not cast to CustomUserDetails. SecurityContextHolder.getContext().getAuthentication().getPrincipal()
is always string , i.e : my username.
Please help if any one solved this problem.