I am using Spring 5 Oauth2. I can see current valid tokens.
Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId("clientIdPassword");
if (tokens != null) {
for (OAuth2AccessToken token : tokens) {
tokenValues.add(token.getValue());
}
}
Above code block shows me valid tokens whose client id is clientIdPassword
, but I want to get only current logged user object. I tried Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
but it returns anonymous user. Is there a way to get the only current logged user object?