How to get OpenId Connect token using Spring Security 5: oauth2Login()?

anschoewe Source

This Spring Security example shows how to configure a simple Spring Boot application with OpenId Connect authentication. It even shows how to retrieve the access_token after the user has successfully authenticated.

    OAuth2AuthorizedClient client = clientService.loadAuthorizedClient(authentication.getAuthorizedClientRegistrationId(), authentication.getName());
    String accessToken = client.getAccessToken().getTokenValue();  

I can't find how to retrieve the original id_token used during authentication. The Oauth2AuthorizedClient only returns the access_token. I need the id_token to send it back to my IdP if I want to end the IdP session (logout).



comments powered by Disqus