title: How to get custom user info from OAuth2 authorization server /user endpoint
body: <p>I have a resource server configured with <code>@EnableResourceServer</code> annotation and it refers to authorization server via <code>user-info-uri</code> parameter as follows:</p>
  
  <pre><code>security:
    oauth2:
      resource:
        user-info-uri: http://localhost:9001/user
  </code></pre>
  
  <p><br>
  Authorization server /user endpoint returns an extension of <code>org.springframework.security.core.userdetails.User</code> which has e.g. an email:</p>
  
  <pre><code>{  
     "password":null,
     "username":"myuser",
      ...
     "email":"me@company.com"
  }
  </code></pre>
  
  <p><br>
  Whenever some resource server endpoint is accessed Spring verifies the access token behind the scenes by calling the authorization server's <code>/user</code> endpoint and it actually gets back the enriched user info (which contains e.g. email info, I've verified that with Wireshark).</p>
  
  <p>So the question is how do I get this custom user info without an explicit second call to the authorization server's <code>/user</code> endpoint. Does Spring store it somewhere locally on the resource server after authorization or what is the best way to implement this kind of user info storing if there's nothing available out of the box?</p>