title: Spring OAuth2 Generate Access Token per request to the Token Endpoint
body: <p>Is it possible to generate multiple valid access tokens using the client_credentials or password grant type per request?</p>
  
  <p>Generating a token using the above grant types only gives a new token when the current one expires per request.</p>
  
  <p>I can use the password grant type to generate a refresh token and then generate multiple access tokens, but doing that will invalidate any previous access tokens.</p>
  
  <p>Any idea how i could change to allow an access token to be generated per request to the  /oauth/token endpoint and insure that any previous tokens are not invalidated?</p>
  
  <p>Below is the XML configuration of my oauth server.</p>
  
  <pre><code>&lt;!-- oauth2 config start--&gt;
    &lt;sec:http pattern="/test/oauth/token" create-session="never"
                authentication-manager-ref="authenticationManager" &gt; 
          &lt;sec:intercept-url pattern="/test/oauth/token" access="IS_AUTHENTICATED_FULLY" /&gt;
          &lt;sec:anonymous enabled="false" /&gt;
          &lt;sec:http-basic entry-point-ref="clientAuthenticationEntryPoint"/&gt;
          &lt;sec:custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" /&gt; 
          &lt;sec:access-denied-handler ref="oauthAccessDeniedHandler" /&gt; 
      &lt;/sec:http&gt;
  
  
      &lt;bean id="clientCredentialsTokenEndpointFilter"
            class="org.springframework.security.oauth2.provider.client.ClientCredentialsTokenEndpointFilter"&gt;
          &lt;property name="authenticationManager" ref="authenticationManager" /&gt;
      &lt;/bean&gt;
  
      &lt;sec:authentication-manager alias="authenticationManager"&gt;
          &lt;sec:authentication-provider user-service-ref="clientDetailsUserService" /&gt;
      &lt;/sec:authentication-manager&gt;
  
      &lt;bean id="clientDetailsUserService"
            class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"&gt;
          &lt;constructor-arg ref="clientDetails" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="clientDetails" class="org.security.oauth2.ClientDetailsServiceImpl"&gt;&lt;/bean&gt;
  
      &lt;bean id="clientAuthenticationEntryPoint"
            class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt;
          &lt;property name="realmName" value="springsec/client" /&gt;
          &lt;property name="typeName" value="Basic" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="oauthAccessDeniedHandler"
            class="org.springframework.security.oauth2.provider.error.OAuth2AccessDeniedHandler"/&gt;
  
      &lt;oauth:authorization-server
          client-details-service-ref="clientDetails" token-services-ref="tokenServices"&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;sec:authentication-manager id="userAuthenticationManager"&gt;
          &lt;sec:authentication-provider  ref="customUserAuthenticationProvider"&gt;
          &lt;/sec:authentication-provider&gt;
      &lt;/sec:authentication-manager&gt;
  
      &lt;bean id="customUserAuthenticationProvider"
            class="org.security.oauth2.CustomUserAuthenticationProvider"&gt;
      &lt;/bean&gt;
  
      &lt;bean id="tokenServices" 
            class="org.springframework.security.oauth2.provider.token.DefaultTokenServices"&gt;
          &lt;property name="tokenStore" ref="tokenStore" /&gt;
          &lt;property name="supportRefreshToken" value="true" /&gt;
          &lt;property name="accessTokenValiditySeconds" value="300"&gt;&lt;/property&gt;
          &lt;property name="clientDetailsService" ref="clientDetails" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.store.JdbcTokenStore"&gt;
          &lt;constructor-arg ref="jdbcTemplate" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jdbcTemplate"
             class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/oauthdb"/&gt;
          &lt;property name="username" value="root"/&gt;
          &lt;property name="password" value="password"/&gt;
      &lt;/bean&gt;
      &lt;bean id="oauthAuthenticationEntryPoint"
            class="org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint"&gt;
      &lt;/bean&gt;
  </code></pre>