This gist describes the configuration required for Spring reactive WebClient to make a call to an OAuth2 protected resource through OAuth2.0 Client Credentials Grant Type Flow.
Assumption is that the Authorization Server supports OpenId Connect 1.0 specifications.
@abhi2495, I get an error when using the exact code.. it seems the oauth client not sending the credentials in the token request
`2020-07-24 02:46:00.960 TRACE 15272 --- [ scheduling-1] o.s.w.r.f.client.ExchangeFunctions : [6ec5c256] HTTP POST http://localhost:8780/auth/realms/ng/protocol/openid-connect/token, headers={masked}
2020-07-24 02:46:01.104 TRACE 15272 --- [ctor-http-nio-2] o.s.http.codec.FormHttpMessageWriter : [6ec5c256] Writing form fields [grant_type, client_id, scope] (content masked)
2020-07-24 02:46:01.173 TRACE 15272 --- [ctor-http-nio-2] o.s.w.r.f.client.ExchangeFunctions : [6ec5c256] Response 401 UNAUTHORIZED, headers={masked}
2020-07-24 02:46:01.216 TRACE 15272 --- [ctor-http-nio-2] o.s.http.codec.json.Jackson2JsonDecoder : [6ec5c256] Decoded [{error=unauthorized_client, error_description=Client secret not provided in request}]
2020-07-24 02:46:01.243 ERROR 15272 --- [ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task
org.springframework.security.oauth2.client.ClientAuthorizationException: [unauthorized_client] Client secret not provided in request
at org.springframework.security.oauth2.client.ClientCredentialsReactiveOAuth2AuthorizedClientProvider.lambda$authorize$0(ClientCredentialsReactiveOAuth2AuthorizedClientProvider.java:82) ~[spring-security-oauth2-client-5.3.3.RELEASE.jar:5.3.3.RELEASE]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ Request to GET http://localhost:8090/app2/api [DefaultWebClient]
Stack trace:
`