Description
Expected Behavior
I want to make some oAuth requests using a loadbalancer. For example, requests to get a token, refresh a token, or request user information. I want to use multiple service instances to make this requests, not just one. For example, I want to use eureka to specify service instance for each token request.
Current Behavior
To make it by hand, I should override beans, that makes this request and set to them custom web client. Example:
@Bean
DefaultReactiveOAuth2UserService defaultReactiveOAuth2UserService() {
var userService = new DefaultReactiveOAuth2UserService();
userService.setWebClient(loadBalancedWebClient);
return userService;
}
@Bean
ReactiveOAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> reactiveOAuth2AccessTokenResponseClient() {
var accessTokenResponseClient = new WebClientReactiveAuthorizationCodeTokenResponseClient();
accessTokenResponseClient.setWebClient(loadBalancedWebClient);
return accessTokenResponseClient;
}
But, for example, it is really hard to set custom web client for AbstractWebClientReactiveOAuth2AccessTokenResponseClient
, which make request to refresh expired token.
Context
Because of this problems, it is really hard to make our microservice system scalable. Framework require to use only one specified server, which is really bad.