title: JHipster AuthorizedFeignClients for microservice to microservice
body: <p>I'm using JHipster v4.5.5 and I'm working through the examples at <a href="https://jhipster.github.io/using-uaa/" rel="nofollow noreferrer">https://jhipster.github.io/using-uaa/</a>. I have two microservices that are trying to communicate. I secured one microservice method with these annotations:</p>
  
  <pre><code>@Secured({AuthoritiesConstants.USER, AuthoritiesConstants.ADMIN})
  </code></pre>
  
  <p>I tried to contact this service from another microservice using an AuthorizedFeignClients:</p>
  
  <pre><code>@AuthorizedFeignClient(name = "MicroService2")
  public interface MicroService2Client {
  
      @RequestMapping(method = RequestMethod.GET, value = "/api/demo/string")
      public String getString();
  ...
  </code></pre>
  
  <p>When I try it, I get:</p>
  
  <pre><code>An unexpected error occurred: status 403 reading MicroService2Client#getString(); content: {"message":"error.accessDenied","description":"Access is denied","fieldErrors":null}
  </code></pre>
  
  <p>What credentials / user is the FeignClient trying to use? Is it the "internal" client defined in application*.yml under the jhipster.security.client-authorization settings? </p>
  
  <p>If so, what annotations should I use on the method to allow this user to access the REST method?</p>
  
  <p>I would prefer that the user account be used and not try to use a service account. I see a note in the documentation that:</p>
  
  <blockquote>
    <p>As an alternative, the access token of the initial request may be forwarded to further calls. Currently, there is no “default solution” provided by JHipster.</p>
  </blockquote>
  
  <p>How do you forward the access token of the original request and forward it on? </p>
  
  <p>I setup a working set of demo projects here:</p>
  
  <ul>
  <li><a href="https://github.com/dapperdanman/MyDemoRegistry" rel="nofollow noreferrer">https://github.com/dapperdanman/MyDemoRegistry</a></li>
  <li><a href="https://github.com/dapperdanman/MyDemoUAA" rel="nofollow noreferrer">https://github.com/dapperdanman/MyDemoUAA</a></li>
  <li><a href="https://github.com/dapperdanman/MyDemoGateway" rel="nofollow noreferrer">https://github.com/dapperdanman/MyDemoGateway</a></li>
  <li><a href="https://github.com/dapperdanman/MyDemoMicroservice1" rel="nofollow noreferrer">https://github.com/dapperdanman/MyDemoMicroservice1</a></li>
  <li><a href="https://github.com/dapperdanman/MyDemoMicroservice2" rel="nofollow noreferrer">https://github.com/dapperdanman/MyDemoMicroservice2</a></li>
  </ul>