1

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.

1 Answer 1

0

Springboot dont provide all of these attributes for you, you can config what you want to see in the /userinfo by this. By default, it will use OAuth2UserService for the response entity

.oauth2Login(oauth2 -> oauth2.userInfoEndpoint())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.