title: Using Basic auth with OAuth2 and JHipster
body: <p>we use jhipster to generate gateway and microservices with OAuth2 authentication, and that works fine with a JHipster Registry and a Keycloak server. But we have a microservice that will be called from an external service, and this service use basic authentication.</p>
  
  <p>So, on the gateway, we need to send login and pasword from basic auth to keycloak server, and use access token to call our service. I get access token by adding filter in MicroserviceSecurityConfiguration class :</p>
  
  <pre><code>http.addFilterBefore(basicAuthFilter, UsernamePasswordAuthenticationFilter.class);
  </code></pre>
  
  <p>And here a extract of filter method :</p>
  
  <pre><code>ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
  details.setAccessTokenUri("http://keycloakserver/auth/realms/jhipster/protocol/openid-connect/token");
  details.setGrantType("password");
  details.setClientId("clientId");
  details.setClientAuthenticationScheme(AuthenticationScheme.form);
  details.setUsername(login);
  details.setPassword(password);
  
  AccessTokenRequest tokenRequest = new DefaultAccessTokenRequest();
  ResourceOwnerPasswordAccessTokenProvider provider = new ResourceOwnerPasswordAccessTokenProvider();
  
  OAuth2AccessToken accessToken = provider.obtainAccessToken(details, tokenRequest);
  </code></pre>
  
  <p>I guess I have to store this token in tokenStore, but I don't know how. So my questions are how use this token, and does the the way I get it is correct ?</p>
  
  <p>Thanks for your help !</p>