title: Authenticate and get to Reddit resource
body: <p>I wanted to call <code>https://oauth.reddit.com/api/v1/me</code> endpoint, so I created follwing REST controller:</p>
  
  <pre><code>@RestController
  @RequestMapping("/reddit")
  public class RedditController {
  
      @Autowired
      private OAuth2RestTemplate redditRestTemplate;
  
      @Value("${secured.service.url:https://oauth.reddit.com/api/v1/me}")
      private String endpoint;
  
      @RequestMapping(value = "/message", method = RequestMethod.GET)
      public String getMessageFromSecuredService(){
          ResponseEntity&lt;String&gt; entity = redditRestTemplate.getForEntity(endpoint, String.class);
          return entity.getBody();
      }
  }
  </code></pre>
  
  <p>To configure authentication I created following configuration:</p>
  
  <pre><code>@Configuration
  @EnableOAuth2Client
  @EnableWebSecurity
  public class KeycloakClientCredentialsConfig extends WebSecurityConfigurerAdapter {
  
      //...
  
      @Override
      public void configure(final WebSecurity web) throws Exception {
          web.ignoring().antMatchers("/**");
      }
  
      @Override
      protected void configure(final HttpSecurity http) throws Exception {
          super.configure(http);
      }
  
      @Bean
      public OAuth2ProtectedResourceDetails oAuth2ProtectedResourceDetails() {
          AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
          details.setId("reddit");
          details.setClientId(clientId);
          details.setClientSecret(clientSecret);
          details.setAccessTokenUri(accessTokenUri);
          details.setUserAuthorizationUri(userAuthorizationUri);
          details.setScope(Arrays.asList("identity", "edit", "flair", "history", "modconfig", "modflair", "modlog", "modposts", "modwiki", "mysubreddits", "privatemessages", "read", "report", "save", "submit", "subscribe", "vote", "wikiedit", "wikiread"));
          details.setPreEstablishedRedirectUri("http://localhost:8080");
          details.setUseCurrentUri(false);
          return details;
      }
  
      @Bean
      public OAuth2RestTemplate createRestTemplate(OAuth2ClientContext clientContext) {
          return new OAuth2RestTemplate(oAuth2ProtectedResourceDetails(), clientContext);
      }
  }
  </code></pre>
  
  <p>However each time I am not getting JSON result, but HTML page so it seems that authentication didn't work.
  Do you know if my configuration is not set correctly? 
  Maybe my REST template should be built on configuration for invoking refresh token endpoint instead of authorize endpoint?</p>