Describe the bug I am building a Spring Boot 3.3.1 app using spring-boot-starter-oauth2-client with GitHub. I have configured the property spring.security.oauth2.client.provider.github.user-name-attribute=name to show the logged in user name instead of id.

However, it is still fetching the claim "id" as name.

Digging into the code, I see while using github provider, in ClientRegistration.java the Builder(String registrationId) constructor is called where it only initializes registrationId and ignores the user-name-attribute property.

To Reproduce Following this official tutorial: https://spring.io/guides/tutorials/spring-boot-oauth2#_social_login_simple.

public static String getCurrentUser() {
        var authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication == null) {
            return null;
        }
        Object principal = authentication.getPrincipal();
        if (principal instanceof OAuth2User) {
             return ((OAuth2User) principal).getName(); <- this is returning the github user id, not name
             //return ((OAuth2User) principal).getAttribute("name"); <- this returns the expected value
        }
        return null;
}

Expected behavior The property spring.security.oauth2.client.provider.github.user-name-attribute=name should be considered and return the name accordingly.

Comment From: sivaprasadreddy

Looks like my IDE caching issue and properties file not updated.

After doing maven clean up and restarting the app, it works fine.