Closed
Description
Summary
We should provide a simple way to integrate OAuth support with RestTemplate. This support would be similar to the WebClient
support, but for RestTemplate
.
The WebClient
extension for Servlet-based applications is ServletOAuth2AuthorizedClientExchangeFilterFunction
.
See the sample oauth2webclient and how to configure and use it.
There are a few tasks involved in order to reach feature parity between ServletOAuth2AuthorizedClientExchangeFilterFunction
and RestTemplate
support. Here is a break-down of the tasks involved.
- User should be able to set the current client using either an
OAuth2AuthorizedClient
orclientRegistrationId
- Each request should contain the
Authorization
header withBearer <access-token>
for the currentOAuth2AuthorizedClient
- Get a new access token if it's not available for the current
clientRegistrationId
- Refresh an expired access token - applicable to
authorization_code
grant clients - Get a new access token when current token expired - applicable to
client_credentials
grant clients - Add clock skew support for access token expiry time