title: Spring MVC - Get access token
body: <p>I am adding OAuth2.0 to secure my WebAPI. I am trying to get a access token while user gets logged in. This is how i tried to get user info after logged in</p>
  
  <pre><code>@RequestMapping(value = "/login/{username}/{password}", method = RequestMethod.GET)
      public ResponseEntity&lt;User&gt; login(@PathVariable String username, @PathVariable String password) {
          if (!username.isEmpty() &amp;&amp; !password.isEmpty()) {
              User user = userService.login(username, password);
              return new ResponseEntity&lt;&gt;(user, HttpStatus.OK);
          }
  
          return new ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);
      } 
  </code></pre>
  
  <p>This is how i implement a code to get access token</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;!-- include this only if you need to authenticate clients via request 
          parameters --&gt;
          &lt;custom-filter ref="clientCredentialsTokenEndpointFilter"
                         after="BASIC_AUTH_FILTER" /&gt;
          &lt;access-denied-handler ref="oauthAccessDeniedHandler" /&gt;
      &lt;/http&gt;
  </code></pre>
  
  <p>I can get access token manually when user hit a correct username and password.
  Now i need to show User details with access token just like below</p>
  
  <pre><code>{ "userId":14, "fullName":"Nishan Dhungana",
  "email":"justin@live.com", "address":"Hokse", "contact":null,
  "dob":null, "active":false, "createdAt":1519196604347,
  "username":"nishanjjj41", "password":"nishan123" , 
  
  "value":"7f228939-5f8e-4c29-b2d9-9ac78d0c16d8",
  "expiration":1519542443387, "tokenType":"bearer" }
  </code></pre>
  
  <p>Is this possible to get user details with access token </p>