<div dir="ltr">Hello,<div><br></div><div>I am trying to find the best way to access the UsersResource.java Rest services outside the keycloak admin application to get a user&#39;s information.  How do I make a request using just the client&#39;s credentials?</div>
<div><br></div><div>I currently use something like this but I get a 401 because I am using a user&#39;s oauth token and they only have user privileges:</div><div><div>SkeletonKeySession session = (SkeletonKeySession) request</div>
<div>                .getAttribute(SkeletonKeySession.class.getName());</div><div>        ResteasyClient client = new ResteasyClientBuilder()</div><div>                .trustStore(session.getMetadata().getTruststore())</div>
<div>                .hostnameVerification(</div><div>                        ResteasyClientBuilder.HostnameVerificationPolicy.ANY)</div><div>                .build();</div><div><br></div><div>        String username = request.getRemoteUser();</div>
<div><br></div><div>        Profile profile = null;</div><div><br></div><div>        try {</div><div><br></div><div>            Response response = client</div><div>                    .target(&quot;<a href="http://server:8080/auth/rest/admin/realms/myrealm/users/">http://server:8080/auth/rest/admin/realms/myrealm/users/</a>&quot;)</div>
<div>                    .path(username)</div><div>                    .request()</div><div>                    .header(HttpHeaders.AUTHORIZATION,</div><div>                            &quot;Bearer &quot; + session.getTokenString()).get();</div>
<div>           </div><div><br></div><div>            // Get the existing entry if there is one. Otherwise, just return</div><div>            // the regular</div><div>            // entity retrieved from the remote system.</div>
<div>            try {</div><div>                profile = profileRepository</div><div>                        .findByRegistrationId(member.getId());</div><div><br></div><div>            } catch (NoResultException e) {</div>
<div>                // ignore</div><div>            }</div><div><br></div><div>        } finally {</div><div>            client.close();</div><div>        }</div></div><div><br></div><div>Is there a way for the application to make a request directly as an admin without giving the user admin privileges?</div>
</div>