<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hey guys,
<div class=""><br class="">
</div>
<div class="">I created a token with&nbsp;/protocol/openid-connect/token and got a JWT token back.</div>
<div class="">Now I am trying to get the username of the logged user from the token via /userinfo.</div>
<div class="">I get the 403 error code.</div>
<div class="">When I was doing that request with the admin user, it worked.</div>
<div class="">I am wondering if I have to set some roles to every user that want to be able to get back their info via /userinfo</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">&nbsp; &nbsp; public User getUserFromToken(String iToken) {</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; HttpClient httpClient = buildHttpClient();</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; HttpGet httpGet = new HttpGet(getKeycloakServerURL() &#43; &quot;/realms/&quot; &#43; getKeycloakRealm() &#43; &quot;/protocol/openid-connect/userinfo&quot;);</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; httpGet.addHeader(&quot;Authorization&quot;, &quot;Bearer &quot; &#43; iToken);</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; try {</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HttpResponse httpResponse = httpClient.execute(httpGet);</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new IllegalStateException(httpGet.toString() &#43; &quot; returned &quot; &#43; httpResponse.getStatusLine().toString());</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String json = IOUtils.toString(httpResponse.getEntity().getContent());</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UserInfo userInfo = JsonSerialization.readValue(json, UserInfo.class);</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return getUser(userInfo.getName(), getKeycloakRealm());</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; } catch (IOException e) {</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new IllegalStateException(e);</div>
<div class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div>
<div class="">&nbsp; &nbsp; }</div>
<div class=""><br class="">
</div>
<div class="">java.lang.IllegalStateException: GET <a href="http://m4ib-idm:8080/auth/realms/imetrik/protocol/openid-connect/userinfo" class="">
http://m4ib-idm:8080/auth/realms/imetrik/protocol/openid-connect/userinfo</a> HTTP/1.1 returned HTTP/1.1 403 Forbidden</div>
<div class=""><br class="">
</div>
<div class="">anything I am missing ?</div>
<div class=""><br class="">
</div>
<div class="">cheers !</div>
<div class=""><br class="Apple-interchange-newline">
<hr align="left" border-color:#40ae49;="" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px; border: 0px; width: 320px; height: 1px; background-color: rgb(64, 174, 73);" class="">
<p class="MsoNormal" style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; orphans: 2; widows: 2; margin: 0cm 0cm 1pt;">
<br style="color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 14px; orphans: auto; widows: auto;" class="">
<span style="color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 14px; orphans: auto; widows: auto; text-transform: uppercase;" class="">REMI CARTIER</span><br style="color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 14px; orphans: auto; widows: auto;" class="">
</p>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="text-align: -webkit-auto; line-height: 14px;" class=""><font color="#666666" face="Helvetica, Arial, sans-serif" class="">B.O.S.S. (Business &amp; Operation Support Systems) P.O (Product Owner)</font></span></div>
<br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<strong style="font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(64, 174, 73); font-family: Helvetica, Arial, sans-serif; line-height: 14px; text-transform: uppercase;" class="">IMETRIK
 GLOBAL INC.</strong><span style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">&nbsp;</span><br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<strong style="font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">T
 :</strong><span style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">&nbsp;&#43;1
 514 448-6407 x2009</span><br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<strong style="font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">T
 :</strong><span style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">&nbsp;&#43;1
 866 276-5382 (toll free)&nbsp;</span><br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<strong style="font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">F
 :</strong><span style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">&nbsp;&#43;1
 514 904-0611&nbsp;</span><br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<span style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">740
 Notre Dame St. West, Suite 1575&nbsp;</span><br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<span style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">Montreal,
 Quebec, Canada H3C 3X6&nbsp;</span><br style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(102, 102, 102); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">
<a href="http://www.imetrik.com/" target="_blank" style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(64, 174, 73); font-family: Helvetica, Arial, sans-serif; line-height: 14px;" class="">imetrik.com</a>
</div>
<br class="">
</div>
</body>
</html>