title: spring oauth2: access_token isn't in response after succefull request
body: <p>i try to authenticated a user on my rest-api with oauth2. But i didn't get the access_token in response after a succefull request. </p>
  
  <p>A part of code: </p>
  
  <p>My ServerConfiguration:</p>
  
  <pre><code>@Configuration
  @EnableResourceServer
  public class OAuth2ServerConfiguration {
  
      @Configuration
      @EnableAuthorizationServer
      protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter {
  
          @Autowired
          private AuthenticationManager authenticationManager;
  
          @Override
          public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
              endpoints.authenticationManager(authenticationManager);
          }
  
          @Override
          public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
              // @formatter:off
              clients.inMemory()
                  .withClient("clientsecret")
                      .authorizedGrantTypes("password")
                      .authorities("USER")
                      .scopes("read")
                      .secret("12345")
                      .accessTokenValiditySeconds(60);
              // @formatter:on
          }
      }
  }
  </code></pre>
  
  <p>my securityconfiguration:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  
      @Override
      protected void configure(AuthenticationManagerBuilder builder) throws Exception {
          builder
              .inMemoryAuthentication()
              .withUser("user").password("password").roles("USER");
      }
  
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  
      @Override
      protected void configure(HttpSecurity security) throws Exception {
          security.authorizeRequests()
              .antMatchers(HttpMethod.GET, "/oauth/token")
              .hasRole("USER")
              .and().httpBasic().realmName("OAuth Server");
      }
  </code></pre>
  
  <p>my controller: </p>
  
  <pre><code>@Path("/oauth")
  @Produces(MediaType.APPLICATION_JSON)
  public class TestController {
  
      @GET
      @Path("/token")
      @Produces(MediaType.APPLICATION_JSON)
      public Response testToken() {
  
          return Response.status(200).entity("is working fine \n")
          .header("Server", "Apache Tomcat/8.0.20")
          .header("Content-Type", MediaType.APPLICATION_JSON)
          .header("Connection", "Opened")
          .type(MediaType.APPLICATION_JSON).build();
      }
  }
  </code></pre>
  
  <p>my request: </p>
  
  <pre><code>curl -X GET -k -vu user:password http://localhost:8080/test/oauth/token -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=password&amp;scope=read&amp;client_secret=12345&amp;client_id=clientsecret"
  </code></pre>
  
  <p>and my response: </p>
  
  <pre><code>*   Trying ::1...
  * Connected to localhost (::1) port 8080 (#0)
  * Server auth using Basic with user 'user'
  &gt; GET /test/oauth/token HTTP/1.1
  &gt; Host: localhost:8080
  &gt; Authorization: Basic dXNlcjpwYXNzd29yZA==
  &gt; User-Agent: curl/7.43.0
  &gt; Accept: */*
  &gt; Content-Type: application/x-www-form-urlencoded
  &gt; Content-Length: 73
  &gt; 
  * upload completely sent off: 73 out of 73 bytes
  &lt; HTTP/1.1 200 OK
  &lt; X-Content-Type-Options: nosniff
  &lt; X-XSS-Protection: 1; mode=block
  &lt; Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  &lt; Pragma: no-cache
  &lt; Expires: 0
  &lt; X-Frame-Options: DENY
  &lt; Set-Cookie: JSESSIONID=0D30F02C6F9A194786581A6C0EB20909; Path=/test/; HttpOnly
  &lt; Server: Apache Tomcat/8.0.20
  &lt; Connection: Opened
  &lt; Content-Type: application/json
  &lt; Transfer-Encoding: chunked
  &lt; Date: Thu, 10 Sep 2015 10:12:39 GMT
  &lt; 
  is working fine 
  * Connection #0 to host localhost left intact
  </code></pre>
  
  <p>what i have to do to see the access_token in response. Why i did get it in json format?</p>
  
  <p>Thank for response.
  Cheers.</p>