We start our new client application by enabling this application as an OAuth 2 client with the addition of the @EnableOAuth2Client annotation. The addition of the @EnableOAuth2Client annotation will allow this application to retrieve and use authorization code grants from one or more OAuth2 authorization server. Client applications that use client credential grants do not need AccessTokenRequest or the scoped RestOperations (the state is global for the applications), but they should still use the filter to trigger OAuth2RestOperations to obtain a token when necessary. Applications that use password grants need to set the authentication properties in OAuth2ProtectedResourceDetails before using the RestOperations method, which we will configure shortly. Let's take a look at the following steps and see how it is done:
- We need to set up a few properties...