Skip to content

Support Sending Json Body instead of Multipart Form Data during WebClientReactive ClientCredentials TokenRequest #14404

@ashetty-boku

Description

@ashetty-boku

I want to send the Oauth Token request sent in case of Grant type Client Credentials as a JSON object
{
"grantType" : "client_credentials"
}
instead of Form data
grant_type=client_credentials

Currently in those discussions I found two approaches
#7781
#8612
One solution is create custom OAuth2ClientCredentialsGrantRequestEntityConverter and other is to use Filters along with BodyInserters, but in both solutions we are able to add/edit the form data object only and not replace it with a json body.

When I try this approach, I can edit the whole body to a String...but I need it to go as Json Object and not Json String enclosed within "" as this below code does

private ExchangeFilterFunction addCustomFilter() {
            return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {

                // Create a new ClientRequest.Builder and set the updated headers
                ClientRequest.Builder newRequestBuilder = ClientRequest.from(clientRequest);
                newRequestBuilder.header("Content-Type", "application/json");
                newRequestBuilder.body(BodyInserters.fromValue("{\"grant_type\": \"client_credentials\"}"));
                return Mono.just(newRequestBuilder.build());
            });
        }

and for OAuth2ClientCredentialsGrantRequestEntityConverter had method createParameters which is supposed to return MultiValueMap<String, String> ....which is again map for constructing form data...so changing request body to Json here wont be possible

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions