oauth2Client is an HttpSecurity configuration method that enables an application to operate as an OAuth 2 client. Calling oauth2Client(Customizer.withDefaults()) activates the client configuration; supporting registration details and a client manager still define how tokens are obtained. section 16.2
Minimal configuration
http.oauth2Client(Customizer.withDefaults()); ClientRegistration.withRegistrationId("1") .clientId("client") .clientSecret("secret") .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) .tokenUri("http://localhost:7070/oauth2/token"); A /token endpoint can invoke the manager and return client.getAccessToken().getTokenValue().
