code: private static void configureOAuth2(RestTemplate restTemplate,
  										ClientHttpRequestFactory clientHttpRequestFactory,
  										String clientId,
  										ClientRegistrationRepository clientRegistrationRepository,
  										OAuth2AuthorizedClientService authorizedClientService) {
  		ClientRegistration clientRegistration = clientRegistrationRepository.findByRegistrationId(clientId);
  
  		if (clientRegistration == null) {
  			throw new IllegalStateException("The CredHub OAuth2 client registration ID '" + clientId +
  					"' is not a valid Spring Security OAuth2 client registration");
  		}
  
  		RestOperations tokenServerRestTemplate = createTokenServerRestTemplate(clientHttpRequestFactory);
  
  		restTemplate.getInterceptors()
  				.add(new CredHubOAuth2RequestInterceptor(tokenServerRestTemplate,
  						clientRegistration, authorizedClientService));
  	}
docs: Configure OAuth2 features of a {@link RestTemplate}.
  
  @param restTemplate                 an existing {@link RestTemplate} to configure
  @param clientHttpRequestFactory     the {@link ClientHttpRequestFactory} to use when
  creating new connections
  @param clientId                     the OAuth2 client ID for authentication
  @param clientRegistrationRepository a repository of OAuth2 client registrations
  @param authorizedClientService      a repository of authorized OAuth2 clients