title: Spring Security OAuth 2: How to get access token and additional data after oauth/token request
body: <p>I'm securing REST services using Spring Security and Oauth 2.0 authentication protocol.</p>
  
  <p>I've implemented a MVC Spring application and it's working fine. 
  Client requests the Server for an AccessToken by providing client credentials (client_id &amp; client_secret) &amp; user credentials (username &amp; password) calling outh/token service which is defined into servlet-config.xml:</p>
  
  <pre><code>&lt;http pattern="/oauth/token" create-session="stateless"
      authentication-manager-ref="clientAuthenticationManager"
      xmlns="http://www.springframework.org/schema/security" &gt; 
      &lt;intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" /&gt;
      &lt;anonymous enabled="false" /&gt;
      &lt;http-basic entry-point-ref="clientAuthenticationEntryPoint" /&gt;
      &lt;custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" /&gt; 
      &lt;access-denied-handler ref="oauthAccessDeniedHandler" /&gt;
   &lt;/http&gt;
  </code></pre>
  
  <p>If credentials are valid, Client will get an Access Token in response like this:</p>
  
  <pre><code>{
      "value": "b663f10d-553d-445b-afde-e9cd84066a1c",
      "expiration": 1406598295994,
      "tokenType": "bearer",
      "refreshToken": {
          "value": "36737abf-24bd-4b86-ad22-601f4d5cdee4",
          "expiration": 1408890295994
      },
      "scope": [],
      "additionalInformation": {},
      "expiresIn": 299999,
      "expired": false
  }
  </code></pre>
  
  <p>I'd like to have a response that also contains user details like this:</p>
  
  <pre><code>{
          "value": "b663f10d-553d-445b-afde-e9cd84066a1c",
          "expiration": 1406598295994,
          "tokenType": "bearer",
          "refreshToken": {
              "value": "36737abf-24bd-4b86-ad22-601f4d5cdee4",
              "expiration": 1408890295994
          },
  
          "additionalInformation": {},
          "expiresIn": 299999,
          "expired": false,
  
          "USER_ID": "1",
          "USER_ROLE": "admin",
          "OTHER DATA..."
      }
  </code></pre>
  
  <p>Does anyone know a way to implement this one? </p>
  
  <p>I've been Googling quite a bit, but I've not found an example implementing a similar scenario. I'm sorry if the question sounds stupid, but I'm very new in Spring Security. </p>