title: Default Authentication not set for Spring Webclient
body: <p>I'm configuring a spring application to use existing authentication in Webclient:</p>
  <p><strong>Flow:</strong></p>
  <p>Client login app -&gt; service1 -&gt; service2</p>
  <p><strong>Webclient service1:</strong></p>
  <pre><code>@Bean
  public WebClient webClient(ClientRegistrationRepository clientRegistrations,
                             OAuth2AuthorizedClientRepository authorizedClients) {
      
      ServletOAuth2AuthorizedClientExchangeFilterFunction oauth2Client =
              new ServletOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients);
      
      oauth2Client.setDefaultOAuth2AuthorizedClient(true);
      
      return WebClient.builder()
              .apply(oauth2Client.oauth2Configuration()) 
              .baseUrl(&quot;some_url&quot;)
              .exchangeStrategies(ExchangeStrategies.builder()
                      .codecs(configurer -&gt;
                              configurer.defaultCodecs()
                                      .maxInMemorySize(2 * 1024)
                      )
                      .build())
              .filter(this.logRequest())
              .build();
  }
  </code></pre>
  <p><strong>service1 Call to service2:</strong></p>
  <pre><code>        Flux&lt;DataBuffer&gt; dataBuffer = webClient
              .get()
              .uri(&quot;some_uri&quot;)
              .accept(MediaType.APPLICATION_OCTET_STREAM, MediaType.ALL)
              .retrieve()
              .bodyToFlux(DataBuffer.class);
  
      DataBufferUtils.write(dataBuffer, Paths.get(joiner.toString()) , StandardOpenOption.CREATE).share().block();
  </code></pre>
  <p>The above fails to add a bearer token to the request, which subsequently fails auth on service2.</p>
  <p>I can add the following to my Webclient:
  <code>oauth2Client.setDefaultClientRegistrationId(&quot;keycloak&quot;);</code>
  This will add a token to each request, but the token is not the existing token available at: <code>SecurityContextHolder.getContext().getAuthentication();</code></p>
  <p>It appears to be a newly requested token using the <code>spring.security.oauth2.client.registration</code> config in the application.properties</p>
  <p>I've been able to get the existing token added to my request, by modifying the call to set the header as follows:</p>
  <pre><code>Flux&lt;DataBuffer&gt; dataBuffer = webClient
              .get()
              .uri(Constant.AQUAMIS_DOCUMENTS_URL + entityId)
              .headers(h -&gt; h.setBearerAuth(keycloakPrincipal.getKeycloakSecurityContext().getTokenString()))
              .accept(MediaType.APPLICATION_OCTET_STREAM, MediaType.ALL)
              .retrieve()
              .bodyToFlux(DataBuffer.class);
  </code></pre>
  <p>I'm unable to get the Webclient to use the existing token, without extracting it from Springs security context and explicitly setting it myself on the Webclient.</p>
  <p>Am I missing something, from the documentation I've read my intial configuration should be reusing the token contained within the spring security context?</p>