title: Multiple Resource server configuration in Spring security OAuth
body: <p>I am trying use a single Auth server to access multiple resource servers from multiple clients.</p>
  
  <p>I am trying to access two resource servers from same auth server and my configuration of resource servers goes as below.</p>
  
  <pre><code>@Bean
  @Scope("prototype") 
  protected ResourceServerConfiguration resource1() {
  
      ResourceServerConfiguration resource = new ResourceServerConfiguration();
      resource.setConfigurers(Arrays.&lt;ResourceServerConfigurer&gt; asList(new ResourceServerConfigurerAdapter() {
      @Override
      public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
          resources.resourceId(RESOURCE_ID1).tokenStore(tokenStore);
      }
  
      @Override
      public void configure(HttpSecurity http) throws Exception {
          http
          .csrf().disable()
          .requestMatchers().antMatchers("/greeting")
          .and()
          .authorizeRequests()
          .antMatchers("/users").hasRole("ADMIN");                
      }
  }   
  resource.setOrder(4);
      return resource;
  }
  
  @Bean
  @Scope("prototype") 
  protected ResourceServerConfiguration resource2() {
      ResourceServerConfiguration resource = new ResourceServerConfiguration();
      resource.setConfigurers(Arrays.&lt;ResourceServerConfigurer&gt; asList(new ResourceServerConfigurerAdapter() {
          @Override
          public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
              resources.resourceId(RESOURCE_ID2).tokenStore(tokenStore);
          }
  
          @Override
          public void configure(HttpSecurity http) throws Exception {
              http
              .csrf().disable()
              .requestMatchers().antMatchers("/welcome")
              .and()
              .authorizeRequests()
              .antMatchers("/users").hasRole("ADMIN");
          }
      }   
      resource.setOrder(5);
      return resource;
  }
  </code></pre>
  
  <p>Since default order of WebSecurityConfigurerAdapter is 3,I have configured the Order of Resource servers as 4 and 5 respectively.</p>
  
  <p>But the configured Beans are getting overridden and I can access the resource "/welcome" which has order 5 and if I try to access the resource "/greeting",I am getting the following error,</p>
  
  <pre><code>{  "timestamp": 1444400211270,  "status": 403,  "error": "Forbidden",  "message": "Expected CSRF token not found. Has your session expired?",  "path": "/greeting"}
  </code></pre>
  
  <p>If I interchange the order between the resources,I can access the resource which has the highest value 5.</p>
  
  <p>Note:I have two clients so that one can access RESOURCE1 and another can access RESOURCE2.</p>
  
  <p>Please advice the things I am missing.</p>