Summary
Not able to add custom parameters to OAuth Token Request as query params
Actual Behavior
- I'm trying to build a custom OAuth2 Access Token request by adding some query params to my Token Request.
- I will later add the access token to my API call as a bearer token.
- I did override OAuth2ClientCredentialsGrantRequestEntityConverter to build my request but I'm not able to fetch the actual API request Parameters to add to the query params for access token URI.
Expected Behavior
- I didn't see any support to add these custom parameters
- I tried using ExchangeFilterFunctions with no luck.
Configuration
Version
org.springframework.security:spring-security-oauth2-client:5.3.2.RELEASE
Sample
This image shows the query params which need to be dynamically populated.
Comment From: eleftherias
@Cheths Can you clarify what you mean by in this sentence?
I did override OAuth2ClientCredentialsGrantRequestEntityConverter to build my request but I'm not able to fetch the actual API request Parameters to add to the query params for access token URI.
Specifically, what do you mean by "the actual API request Parameters"?
I noticed you have assigned defaultRequestEntityConverter, but are not using it.
If you are trying to get the query parameters that are added in OAuth2ClientCredentialsGrantRequestEntityConverter, then you can get those by using thedefaultRequestEntityConverter:
RequestEntity<?> entity = defaultRequestEntityConverter.convert(clientCredentialsGrantRequest);
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: Cheths
@eleftherias - Sorry for the delay in the response.
Context: - I'm trying to invoke an API that will be intercepted by a custom implementation of ClientHttpRequestInterceptor where it will request for an OAuth token and attach it as a Bearer token to the headers of the API request - The OAuth2 token endpoint is a custom rest API endpoint that calls another service to fetch the token. The token URL requires URL parameters id and account Number to generate a token.
Issue: In order to get the OAuth2 token, I need some custom parameters from the headers of the API request to be passed to the Custom converter method seen in the attached image. I did not find a way to do this.