We are using spring security oauth2 to obtain token using client credentials grant type. We are not using the application.properties
file for specifying the client credentials, instead we are supplying them programmatically.
ClientRegistration clientRegistration = ClientRegistration
.withRegistrationId("test")
.clientId("testclientid")
.clientSecret("testclientsecret")
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
.tokenUri("http://test.tokenuri.com")
.build();
ReactiveClientRegistrationRepository reactiveClientRegistrationRepository = new InMemoryReactiveClientRegistrationRepository(clientRegistration);
ServerOAuth2AuthorizedClientExchangeFilterFunction oauth =
new ServerOAuth2AuthorizedClientExchangeFilterFunction(
reactiveClientRegistrationRepository,
new UnAuthenticatedServerOAuth2AuthorizedClientRepository());
oauth.setDefaultClientRegistrationId("test");
this.webClient = webClientFactory.getBuilder()
.filter(oauth)
.build();
The code is working fine, but we see a warning that UnAuthenticatedServerOAuth2AuthorizedClientRepository
is deprecated.
The api docs for UnAuthenticatedServerOAuth2AuthorizedClientRepository
recommend to use AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager
instead, but AuthorizedClientServiceReactiveOAuth2AuthorizedClientManager
does not implement the same interface as UnAuthenticatedServerOAuth2AuthorizedClientRepository
. What is the recommendation on replacing the deprecated UnAuthenticatedServerOAuth2AuthorizedClientRepository
in this case?
I found https://github.com/spring-projects/spring-security/issues/8016 but the issue does not give much detail.