title: Request new access token using refresh token in username-password grant in Spring Security OAuth2
body: <p>We're using the username-password grant to obtain an access token from our auth server. We want to refresh the access token before it expires using the provided refresh token until the user logs out or closes the client app. </p>
  
  <p>However I just cannot find any examples of how to issue this refresh token request..</p>
  
  <p>To obtain the token we call something like:</p>
  
  <pre><code>curl -v --data "grant_type=password&amp;username=user&amp;password=pass&amp;client_id=my_client" http://localhost:8080/oauth/token
  </code></pre>
  
  <p>So to refresh I'd expect the call to look like this:</p>
  
  <pre><code>curl -v --data "grant_type=refresh_token&amp;access_token=THE_ACCESS_TOKEN&amp;refresh_token=THE_REFRESH_TOKEN" http://localhost:8080/oauth/token
  </code></pre>
  
  <p>or maybe </p>
  
  <pre><code>curl -v -H "Authorization: Bearer THE_ACCESS_TOKEN" --data "grant_type=refresh_token&amp;refresh_token=THE_REFRESH_TOKEN" http://localhost:8080/oauth/token
  </code></pre>
  
  <p>But it will just give me a 401..</p>
  
  <p>Oh yeah, maybe I need to add the clientId? I cannot use the client secret, because there is none (see above request to obtain the token). Authentication is done using username and password after all..</p>
  
  <p>I think we have the server configuration right, so I'll not post it here. If one of my example requests should work and you need to see the important config parts I'll add them.</p>
  
  <p>Thanks!</p>