I just set-up the Oauth2 flow by means of SpringBoot 3.x framework and Google.
Using the
securityBuilder.oauth2Login(oauth2 -> oauth2.successHandler(authenticationSuccessHandler));
I'm able to call a custom callback method and retrieve the standard attributes from the Oauth2User object:
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException, ServletException {
log.info("Oauth2 authentication successful");
OAuth2User oAuth2User = (OAuth2User) authentication.getPrincipal();
The OAuth2User object contains the standard "claims" : sub, name, family_name, email and so on and so forth.
Through the google admin console I added a custom attribute to my Google users but I don't see it within the OAuth2User attributes retrieved by SpringBoot (I suppose it is using the https://www.googleapis.com/oauth2/v3/userinfo API call).
What I'm missing ?
Thanks in advance, Mauro.