I have successfully integrated Spring Security OAuth2 with my Open ID Connect provider (Forgerock OpenAM). I can see the access token being retrieved. How can I access the id_token and refresh_token which are part of the response from the /token endpoint?
I know this is an old thread, but I hope this helps anyone looking for the response.
Use your “Authentication authentication” object:
OAuth2AuthenticationToken oauth2Auth = (OAuth2AuthenticationToken) authentication;
String idToken = ((DefaultOidcUser) oauth2Auth.getPrincipal()).getIdToken().getTokenValue();
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With