OAuth2 Authorized Client
Spring framework provides WebClient as part of Webflux for reactive environment. There is integration with OAuth2 framework, so you can write clients which access protected resources by utilizing OAuth2AuthorizedClient. The framework authorizes client on background by requesting access token from configured OAuth2 Resource Server using supported method: * authorization_code - triggers the Authorization Request redirect to initiate the flow * client_credentials - the access token is obtained directly from the Token Endpoint * password - the access token is obtained directly from the Token Endpoint
There are additional capabilities added to Web client: * Refresh of access token automatically on background * Credentials storage
The OAuth2 client must ber first registered into framework and then it can be used by WebClient. Spring uses SecurityWebFilterChain to plug the authorization in client call. Reactive WebClient is configured with ExchangeFilterFunction: