title: Invalid token in spring boot resource server
body: <p>Hello guys</p>
  
  <p>I need some help in my problem. I can get token from my authorization server.</p>
  
  <p>**That server using Oracle database.</p>
  
  <p>For example </p>
  
  <p>grant_type = client_credentials</p>
  
  <p>clientId = curlclient</p>
  
  <p>clientSecret = test</p>
  
  <p><a href="http://localhost:8885/oauth/token" rel="nofollow noreferrer">http://localhost:8885/oauth/token</a></p>
  
  <p>After, I try to access resource server by the using result access token. But I can't.</p>
  
  <p>Result is:</p>
  
  <pre><code>{
      "error": "invalid_token",
      "error_description": "b95b8ad3-d030-460d-bee2-ce781b3d4b95"
  }
  </code></pre>
  
  <p>Here is my codes:</p>
  
  <p>Resource config:</p>
  
  <pre><code>@Configuration
  @EnableResourceServer
  public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
      @Bean
      @ConfigurationProperties(prefix="spring.datasource")
      public DataSource ouathDataSource(){return DataSourceBuilder.create().build();}
  
      @Override
      public void configure(ResourceServerSecurityConfigurer resources)throws Exception {
          TokenStore tokenStore=new JdbcTokenStore(ouathDataSource());
          resources.resourceId("product_api").tokenStore(tokenStore);
  
      }
      @Override
  
      public void configure(HttpSecurity http) throws Exception{
          http
                  .authorizeRequests()
                  .antMatchers(HttpMethod.GET, "/actuator/**").permitAll()
                  .antMatchers(HttpMethod.GET,"/datatest").access("#oauth2.hasScope('write')")
                  .antMatchers(HttpMethod.GET, "/**").access("#oauth2.hasScope('write')")
                  .antMatchers(HttpMethod.POST, "/**").access("#oauth2.hasScope('write')")
                  .antMatchers(HttpMethod.PATCH, "/**").access("#oauth2.hasScope('write')")
                  .antMatchers(HttpMethod.PUT, "/**").access("#oauth2.hasScope('write')")
                  .antMatchers(HttpMethod.DELETE, "/**").access("#oauth2.hasScope('write')");
      }
  }
  </code></pre>
  
  <p>Authorization config:</p>
  
  <pre><code>@Configuration
  @EnableAuthorizationServer
  public class AuthServerConfig extends AuthorizationServerConfigurerAdapter {
  
      @Bean
      @ConfigurationProperties(prefix = "spring.datasource")
      public DataSource oauthDataSource() {
          return DataSourceBuilder.create().build();
  
      }
  
      @Bean
      public JdbcClientDetailsService clientDetailsService() {
          return new JdbcClientDetailsService(oauthDataSource());
      }
  
      @Bean
      public TokenStore tokenStore() {
          return new JdbcTokenStore(oauthDataSource());
      }
  
      @Bean
      public ApprovalStore approvalStore() {
          return new JdbcApprovalStore(oauthDataSource());
      }
  
      @Bean
      public AuthorizationCodeServices authorizationCodeServices() {
          return new JdbcAuthorizationCodeServices(oauthDataSource());
      }
  
      @Override
      public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
          clients.withClientDetails(clientDetailsService());
      }
  
      @Override
      public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
  
      }
  
      @Override
      public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
          endpoints
                  .approvalStore(approvalStore())
                  .authorizationCodeServices(authorizationCodeServices())
                  .tokenStore(tokenStore());
      }
  }
  </code></pre>
  
  <p>WebSecurity config:</p>
  
  <pre><code>@EnableWebSecurity
  @Configuration
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      @Bean
      public PasswordEncoder passwordEncoder() {
          return new BCryptPasswordEncoder();
      }
  
      @Autowired
      private JdbcUserDetails jdbcUserDetails;
  
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.userDetailsService(jdbcUserDetails).passwordEncoder(passwordEncoder());
      }
  }
  </code></pre>
  
  <p>Help me!!!!!!!!!</p>