title: Spring Oauth2 - Customizing TokenEndpoint from @RequestParam to @RequestBody
body: <p>I use the standard configuration of Spring-Security, this is my pom.xml:</p>
  
  <pre><code>    &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.5.8.RELEASE&lt;/version&gt;
          &lt;relativePath&gt;&lt;/relativePath&gt;
      &lt;/parent&gt;
  
  &lt;dependencies&gt;
          &lt;!-- Spring --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security.oauth&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-oauth2&lt;/artifactId&gt;
          &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>I must change the standard token request:</p>
  
  <p>Original token request:</p>
  
  <pre><code>@RequestMapping(value = "/oauth/token", method=RequestMethod.GET)
  public ResponseEntity&lt;OAuth2AccessToken&gt; getAccessToken(Principal principal, @RequestParam Map&lt;String, String&gt; parameters) throws HttpRequestMethodNotSupportedException
  </code></pre>
  
  <p>Desiderate token request</p>
  
  <pre><code>@RequestMapping(value = "/oauth/login", method=RequestMethod.POST)
  public ResponseEntity&lt;OAuth2AccessToken&gt; postAccessToken(Principal principal, @RequestBody UserLogin userLogin) throws HttpRequestMethodNotSupportedException
  </code></pre>
  
  <p>Is it possibile?</p>
  
  <p>I extend TokenEndpoint like this but doesn't work:</p>
  
  <pre><code>public class CustomTokenEndpoint extends TokenEndpoint {
  
  @RequestMapping(value = "/oauth/login", method=RequestMethod.POST)
  public ResponseEntity&lt;OAuth2AccessToken&gt; postAccessToken(Principal principal, @RequestBody UserLogin userLogin) throws HttpRequestMethodNotSupportedException {
          return postAccessToken(principal, userLogin.getParameters());
      }
  }
  </code></pre>