Oauth2ClientRestTemplate { public OAuth2RestOperations authorizationCodeRestTemplate(String client_id, String client_secret, String authorization_uri, String access_token_uri, String... scope) { if (!access_token_uri.contains("token") || !authorization_uri.contains("authorize")) throw new RuntimeException("uri is wrong : access_token_uri = " + access_token_uri + " , authorization_uri" + authorization_uri); AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); details.setId("1"); details.setClientId(client_id); if (client_secret != null && !client_secret.isEmpty()) details.setClientSecret(client_secret); details.setAccessTokenUri(access_token_uri); details.setUserAuthorizationUri(authorization_uri); details.setUseCurrentUri(true); details.setScope(Arrays.asList(scope)); return new OAuth2RestTemplate(details, oAuth2ClientContext); }  OAuth2RestOperations authorizationCodeRestTemplate(String client_id, String client_secret, String authorization_uri, String access_token_uri, String... scope); @Deprecated OAuth2RestOperations implicitResourceRestTemplate(String client_id, String client_secret, String authorization_uri, String access_token_uri, String... scope); @Deprecated OAuth2RestOperations resourceOwnerPasswordRestTemplate(String client_id, String client_secret, String access_token_uri, String username, String password, String... scope); OAuth2RestOperations clientCredentialsRestTemplate(String client_id, String client_secret, String access_token_uri, String... scope);  }
@Test public void testAuthorizationCodeRestTemplate() throws Exception { OAuth2RestOperations operations = restTemplate.authorizationCodeRestTemplate(client_id, client_secret, access_token_uri, user_authorization_uri, scopes); System.out.println(JSON.toJSONString(operations.getForObject(source_url, JsonNode.class))); }