0

I'm currently implementing a simple spring-boot backend that pulls data from different services. One of those services requires authentication through client credentials. For some reason, some of the data I need to access also requires additional user credentials as part of the request body when trying to create an access token.

I've been following this tutorial on the client credential grant. (The author of this article specifically states that you typically don't have any user context when using client credentials so I'm not sure if this approach is even applicable in my case.)

So far I tried experimenting with the OAuth2AuthorizedClientProvider and the OAuth2AuthorizeRequest trying to somehow add a request body that lets me pass the user credentials. I had hoped that just like in Postman where you can add parameters to a Token Request, I could do something like the following:

OAuth2AuthorizeRequest authorizeRequest = OAuth2AuthorizeRequest.withClientRegistrationId("qid")
                .attribute(OAuth2ParameterNames.RESOURCE, credentials)
                .principal("Demo Service")
                .build();

RESOUCE isn't a valid constant but it would be the parameter I'm supposed to add. So far I haven't had any luck with it and am looking for hints or resources that can point me in the right direction.

As you can probably tell from the question I'm pretty new to this topic so any advice is appreciated.

Ajeet Verma
  • 2,938
  • 3
  • 13
  • 24
speciial
  • 1
  • 1

0 Answers0