Expected Behavior

To not throw an exception and create Map<String, ClientRegistration> properly

Current Behavior

Throws java.lang.NoClassDefFoundError

Caused by: java.lang.NoClassDefFoundError: org/springframework/security/config/oauth2/client/CommonOAuth2Provider
    at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper.getCommonProvider(OAuth2ClientPropertiesMapper.java:139)
    at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper.getBuilder(OAuth2ClientPropertiesMapper.java:107)
    at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper.getClientRegistration(OAuth2ClientPropertiesMapper.java:73)
    at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper.lambda$asClientRegistrations$0(OAuth2ClientPropertiesMapper.java:65)
    at java.base/java.util.HashMap.forEach(HashMap.java:1430)
    at org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientPropertiesMapper.asClientRegistrations(OAuth2ClientPropertiesMapper.java:64)

Context We are trying to create client registrations as follows

OAuth2ClientProperties oAuth2ClientProperties = ...
var clientRegistrations = new OAuth2ClientPropertiesMapper(oAuth2ClientProperties) .asClientRegistrations()

We don't want to include org.springframework.security:spring-security-config as dependency and we don't have any google, github, facebook, okta OAuth2 provider types configured.

Two workaround we found. We copy/pasted OAuth2ClientPropertiesMapper in our code base patch related code to be conditional depending on CommonOAuth2Provider presence.

Obviously second workaround is to include spring-security-config dependency, but we don't want security autoconfiguration to kick in, still struggling to exclude all relevant autoconfigurations.

Comment From: nstdio

I didn't notice the package of OAuth2ClientPropertiesMapper assuming it was part of Spring Security. Can you please transfer this issue to Spring Boot project?