title: Spring Security Oauth 2 custom token end point url
body: <p>Hello I have to integrate spring security oauth2 in my project. So I added the configuration related part and its working fine. But the problem is that the first request for token goes to "/oauth/token"  and I want to change it to "api/v1/token" .
  I searched for that and find some solution like adding <code>token-endpoint-url</code> in <code>oauth:authorization-server</code> also adding custom filter class that will override <code>ClientCredentialsTokenEndpointFilter</code> and passing the url to constructor. But these didn't worked . 
  I am getting following error for request to "api/v1/token"-</p>
  
  <blockquote>
    <p>An Authentication object was not found in the SecurityContext</p>
  </blockquote>
  
  <p>My configuration is mainly xml based .
  Spring-security.xml file-</p>
  
  <pre><code>&lt;http pattern="/api/v1/token" create-session="stateless"
        authentication-manager-ref="authenticationManager"
        xmlns="http://www.springframework.org/schema/security" &gt; 
      &lt;intercept-url pattern="/api/v1/token" access="IS_AUTHENTICATED_FULLY" /&gt;
      &lt;anonymous enabled="false" /&gt;
      &lt;http-basic entry-point-ref="clientAuthenticationEntryPoint"/&gt;
      &lt;custom-filter ref="customClientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" /&gt; 
      &lt;access-denied-handler ref="oauthAccessDeniedHandler" /&gt;
  &lt;/http&gt;
  &lt;http pattern="/test/**" create-session="never"
        entry-point-ref="oauthAuthenticationEntryPoint"       
        xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;anonymous enabled="false" /&gt;
      &lt;intercept-url pattern="/test/**" access="ROLE_USER" /&gt;
      &lt;custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" /&gt;
      &lt;access-denied-handler ref="oauthAccessDeniedHandler" /&gt;
  &lt;/http&gt;
  &lt;beans:bean id="oauthAuthenticationEntryPoint"
              class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt;
  &lt;/beans:bean&gt;
   &lt;beans:bean id="oauthAccessDeniedHandler"
      class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler"&gt;
  &lt;/beans:bean&gt;
  &lt;beans:bean id="clientAuthenticationEntryPoint"
              class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt;
      &lt;beans:property name="realmName" value="springsec/client" /&gt;
      &lt;beans:property name="typeName" value="Basic" /&gt;
  &lt;/beans:bean&gt;
  
  
   &lt;beans:bean id="customClientCredentialsTokenEndpointFilter"
              class="com.walletdoc.oauth.web.security.CustomClientCredentialsTokenEndpointFilter"&gt;
       &lt;beans:property name="authenticationManager" ref="authenticationManager" /&gt;
  &lt;/beans:bean&gt;
  
  &lt;authentication-manager alias="authenticationManager"
                          xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;authentication-provider user-service-ref="clientDetailsUserService" /&gt;
  &lt;/authentication-manager&gt;
  &lt;beans:bean id="clientDetails" class="com.walletdoc.oauth.web.security.SpringSecurityClientService"&gt;
      &lt;beans:property name="id" value="mysupplycompany" /&gt;
      &lt;beans:property name="secretKey" value="mycompanykey" /&gt;
      &lt;beans:property name="authorities" value="ROLE_CLIENT" /&gt;
  &lt;/beans:bean&gt;
  &lt;beans:bean id="clientDetailsUserService"
              class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"&gt;
      &lt;beans:constructor-arg ref="clientDetails"/&gt;
  &lt;/beans:bean&gt;
  
  
  
  &lt;authentication-manager id="userAuthenticationManager" 
                          xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;authentication-provider  ref="customUserAuthenticationProvider"&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  
  &lt;beans:bean id="customUserAuthenticationProvider"
              class="com.walletdoc.oauth.web.security.ClientAuthenticationProvider"&gt;
  &lt;/beans:bean&gt;
  
  &lt;oauth:authorization-server
      client-details-service-ref="clientDetails" token-services-ref="tokenServices" token-endpoint-url="/api/v1/token"&gt;
      &lt;oauth:authorization-code /&gt;
      &lt;oauth:implicit/&gt;
      &lt;oauth:refresh-token/&gt;
      &lt;oauth:client-credentials /&gt;
      &lt;oauth:password authentication-manager-ref="userAuthenticationManager" /&gt;
  &lt;/oauth:authorization-server&gt;
  
  &lt;oauth:resource-server id="resourceServerFilter"
                         resource-id="springsec" token-services-ref="tokenServices" /&gt;
  
  &lt;beans:bean id="tokenStore"
              class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore" /&gt;
  
  &lt;beans:bean id="tokenServices"
              class="org.springframework.security.oauth2.provider.token.DefaultTokenServices"&gt;
      &lt;beans:property name="tokenStore" ref="tokenStore" /&gt;
      &lt;beans:property name="supportRefreshToken" value="true" /&gt;
      &lt;beans:property name="accessTokenValiditySeconds" value="3600"&gt;&lt;/beans:property&gt;
      &lt;beans:property name="clientDetailsService" ref="clientDetails" /&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>I have been trying to solve this issue from last 2 days ,so any help will be appreciated.</p>