title: Spring OAUTH: Override CheckTokenEndpoint 'check_token?token=' response map
body: <p>I would like to override the CheckTokenEndpoint to provide my own custom output as Map to the resource server. I have tried the following, but not working.</p>
  
  <ol>
  <li>Introducing new custom controller for (/oauth/check_token), but Spring rejects this custom and registers its own. </li>
  </ol>
  
  <blockquote>
    <p>Overriding bean definition for bean 'checkTokenEndpoint' with a
    different definition: replacing [Generic bean: class
    [com.datami.auth.security.CheckTokenEndpoint]; scope=singleton;
    abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0;
    autowireCandidate=true; primary=false; factoryBeanName=null;
    factoryMethodName=null; initMethodName=null; destroyMethodName=null;
    defined in file
    [/usr/local/Cellar/tomcat/8.5.5/libexec/webapps/oauth-server/WEB-INF/classes/com/datami/auth/security/CheckTokenEndpoint.class]]
    with [Root bean: class [null]; scope=; abstract=false; lazyInit=false;
    autowireMode=3; dependencyCheck=0; autowireCandidate=true;
    primary=false;
    factoryBeanName=org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration;
    factoryMethodName=checkTokenEndpoint; initMethodName=null;
    destroyMethodName=(inferred); defined in class path resource
    [org/springframework/security/oauth2/config/annotation/web/configuration/AuthorizationServerEndpointsConfiguration.class]]</p>
  </blockquote>
  
  <ol start="2">
  <li><p>Created my own endpoint with (<code>/oauth/check_custom_token</code>) but not sure autowiring resourceServerTokenServices in the below, @autowire doesn't helped me.</p>
  
  <p>@autowire <BR>
  private ResourceServerTokenServices resourceServerTokenServices;</p></li>
  </ol>
  
  <p>Spring has autowired this with <code>DefaultTokenServices</code>.</p>
  
  <p>I can also create <code>new DefaultTokenServices()</code> in my code, but then how to autowire the below inside DefaultTokenServices? again the same problem.</p>
  
  <pre><code>private TokenStore tokenStore;
  
  private ClientDetailsService clientDetailsService;
  
  private TokenEnhancer accessTokenEnhancer;
  
  private AuthenticationManager authenticationManager; 
  </code></pre>
  
  <p>Coul you please help me out.</p>