-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Allow to set custom BodyExtractor for OAuth 2.0 access token response #7709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@rchigvintsev Have you considered supplying a custom ExchangeFilterFunction tokenResponseFilter = ExchangeFilterFunction.ofResponseProcessor(response -> {
ClientResponse.Builder builder = ClientResponse.from(response);
// TODO Change response body and set token_type to Bearer
return Mono.just(builder.build());
});
WebClient webClient = WebClient.builder()
.filter(tokenResponseFilter)
.build(); This configuration should allow you to post-process the response and return a modified response before the default |
@jgrandja
|
IMO, it's pretty similar but it does help with reading/writing the response body which is convenient. However, there are quite a few configuration points for If we were to provide I'm reluctant on adding this since you can directly configure |
@jgrandja |
Thank you for understanding @rchigvintsev |
@rchigvintsev would you mind sharing how you have transformed response. |
@avinashkris9 Yes, certainly. Here is my filter function with several additional methods:
|
@rchigvintsev thanks ! |
Recently I faced the issue when some OAuth 2.0 provider did not return token type in the access token response. Spring expects "token_type" parameter and throws exception when it is missing. The solution I came up was to change response body and set token type "Bearer" manually. For now it is not easy to do since
org.springframework.security.oauth2.client.endpoint.WebClientReactiveAuthorizationCodeTokenResponseClient
does not expose any of its logic related to response reading. I think ability to set customBodyExtractor
could facilitate this task.The text was updated successfully, but these errors were encountered: