title: How to use RemoteTokenService?
body: <p>I have a separate ResourceServer built using Spring-Security-oauth2. Here is the code RemoteTokenService.</p>
  
  <pre><code>@Bean
  public ResourceServerTokenServices tokenService() {
     RemoteTokenServices tokenServices = new RemoteTokenServices();
     tokenServices.setClientId("sample_test_client_app");
     tokenServices.setClientSecret("secret");
     tokenServices.setCheckTokenEndpointUrl("http://localhost:8080/oauth/check_token");
     return tokenServices;
  }
  </code></pre>
  
  <p>When I'm accessing the resource server with AccessToken I get the following: </p>
  
  <pre><code>FilterSecurityInterceptor - Secure object: FilterInvocation: URL: /oauth/check_token; Attributes: [denyAll()]
  FilterSecurityInterceptor - Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@c3f3b25: Principal: org.springframework.security.core.userdetails.User@3c0cd8e: Username: sample_test_client_app; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Not granted any authorities; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Not granted any authorities
  AffirmativeBased - Voter: org.springframework.security.web.access.expression.WebExpressionVoter@6172e10, returned: -1
  ExceptionTranslationFilter - Access is denied (user is not anonymous); delegating to AccessDeniedHandler
  </code></pre>
  
  <p>Can any one tell me what is wrong with my configuration ?</p>
  
  <p><strong>Update :</strong>
  My Spring security configuration.</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  
          auth.inMemoryAuthentication().withUser("developer").password("developer").roles("USER");
  
      }
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          web.ignoring().antMatchers("/webjars/**", "/images/**", "/oauth/uncache_approvals", "/oauth/cache_approvals");
      }
  
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          // @formatter:off
                   http
              .authorizeRequests().antMatchers("/login.jsp").permitAll().and()
              .authorizeRequests().antMatchers("/oauth/check_token").permitAll().and()
              .authorizeRequests()
                  .anyRequest().hasRole("USER")
                  .and()
              .exceptionHandling()
                  .accessDeniedPage("/login.jsp?authorization_error=true")
                  .and()
              .logout()
                  .logoutSuccessUrl("/index.jsp")
                  .logoutUrl("/logout.do")
                  .and()
              .formLogin();
          // @formatter:on
      }
  }
  </code></pre>
  
  <p>My Auth server configuration.</p>
  
  <pre><code>@Configuration
      @EnableAuthorizationServer
      protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {
  
          @Autowired
          private TokenStore tokenStore;
  
          @Autowired
          private UserApprovalHandler userApprovalHandler;
  
          @Autowired
          @Qualifier("authenticationManagerBean")
          private AuthenticationManager authenticationManager;
  
          @Override
          public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
              // @formatter:off
              clients
                  .inMemory()
                  .withClient("sample_test_client_app")
                  .secret("secret")
                  .authorizedGrantTypes("client_credentials","authorization_code")
                  .authorities("ROLE_CLIENT")
                  .resourceIds(CHANAKYA_RESOURCE_ID)
                  .scopes("read","write");
  
              // @formatter:on
          }
  
          @Bean
          public TokenStore tokenStore() {
              return new InMemoryTokenStore();
          }
  
          @Override
          public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
              endpoints.tokenStore(tokenStore).userApprovalHandler(userApprovalHandler)
                      .authenticationManager(authenticationManager);
          }
  
          @Override
          public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
              oauthServer.realm("resource_server/client");
          }
  
      }
  </code></pre>