title: Consider defining a bean of type 'org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository' in your configuration
body: <p>I am using spring oAuthClient version 5.2.4.RELEASE 
  By following the document link of spring security 
  <a href="https://docs.spring.io/spring-security/site/docs/current/reference/html5/#oauth2Client-authorized-manager-provider" rel="noreferrer">https://docs.spring.io/spring-security/site/docs/current/reference/html5/#oauth2Client-authorized-manager-provider</a></p>
  
  <pre><code>    import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
  import org.springframework.security.oauth2.client.web.reactive.function.client.ServerOAuth2AuthorizedClientExchangeFilterFunction;
  import org.springframework.security.oauth2.client.web.server.ServerOAuth2AuthorizedClientRepository;
  import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
  import org.springframework.web.reactive.function.client.WebClient;
  
  import lombok.AllArgsConstructor;
  import lombok.extern.slf4j.Slf4j;
  import reactor.core.publisher.Mono;
  
  @AllArgsConstructor
  @Configuration
  @Slf4j
  public class WebClientConfig {
  
      @Bean("AuthProvider")
      WebClient webClient(ReactiveClientRegistrationRepository clientRegistrations, ServerOAuth2AuthorizedClientRepository authorizedClients) {
          ServerOAuth2AuthorizedClientExchangeFilterFunction oauth = new ServerOAuth2AuthorizedClientExchangeFilterFunction(
                  clientRegistrations,
                  authorizedClients);
          oauth.setDefaultOAuth2AuthorizedClient(true);
          oauth.setDefaultClientRegistrationId("AuthProvider");
          return WebClient.builder()
                  .filter(oauth)
                  .filter(this.logRequest())
                  .build();
      }
  
  
      private ExchangeFilterFunction logRequest() {
          return ExchangeFilterFunction.ofRequestProcessor(clientRequest -&gt; {
              log.info("Request: [{}] {}", clientRequest.method(), clientRequest.url());
              log.debug("Payload: {}", clientRequest.body());
              return Mono.just(clientRequest);
          });
      }
  </code></pre>
  
  <p>application.yaml </p>
  
  <pre><code>   security:
      oauth2:
        client:
          provider:
            AuthProvider:
              token-uri: ${tokenpath&lt;read from environment variable&gt;}
          registration:
            AuthProvider:
              authorization-grant-type: client_credentials
              client-id: ${&lt;read from environment variable&gt;}
              client-secret: ${&lt;read from environment variable&gt;}
  </code></pre>
  
  <p>Getting the following error</p>
  
  <pre><code>    ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Parameter 0 of method webClient in com.sample.config.WebClientConfig required a bean of type 'org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository' that could not be found.
  
  The injection point has the following annotations:
      - @org.springframework.beans.factory.annotation.Autowired(required=true)
  
  
  Action:
  
  Consider defining a bean of type 'org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository' in your configuration.
  </code></pre>
  
  <p><strong>Let me know, if I missed any configuration as didnot get any specific help from other questions of stackoverflow</strong></p>