title: Spring Security Oauth2 - Adding credentials to the AccessTokenRequest
body: <p>With <a href="http://projects.spring.io/spring-security-oauth/docs/oauth2.html" rel="nofollow">this reference</a> to the Spring OAuth2 Client docs:</p>
  
  <p>And the following section:</p>
  
  <blockquote>
    <p>If you desparately need password grants to work from a Java client, then use the same mechanism to configure your OAuth2RestTemplate and add the credentials to the AccessTokenRequest (which is a Map and is ephemeral) not the ResourceOwnerPasswordResourceDetails (which is shared between all access tokens).</p>
  </blockquote>
  
  <p>How can the credentials be added to the AccessTokenRequest? Or more generally, how can I get a reference to the AccessTokenRequest or OAuth2ClientContext for the specific user of the request.</p>
  
  <p>The reason why I need this is to avoid the UserRedirectRequiredException and the requirement to redirect to the authorize URL, as the Rest API I am accessing does not have a login page, but just a restful login api. </p>
  
  <p>Supposedly the OAuth2ClientContextFilter should store the current request and context but I can't see how.</p>