<p dir="ltr">If you are not running on the CORS issue, have you tried to set your web origins properly?<br>
Remember that <a href="http://localhost:8080">http://localhost:8080</a> != localhost:8080</p>
<div class="gmail_quote">On Feb 16, 2016 14:55, "LEONARDO NUNES" <<a href="mailto:leo.nunes@gjccorp.com.br">leo.nunes@gjccorp.com.br</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:16px;font-family:Calibri,sans-serif">
<div>
<div>
<div>Stian, so how do I restrict URLs?</div>
<div>Do I need to place the keycloakAuth.init({ onLoad: 'login-required' }) at all pages I what to restrict and keycloakAuth.init({ onLoad: 'check-sso' }) at pages not restricted?</div>
<div><br>
</div>
<div>Does keycloakAuth.init({ onLoad: 'login-required' }) really login the user every time it's called?</div>
<div>Because my listener that implements EventListenerProvider enters the onEvent with EventType LOGIN every time init method is called.</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>-- </div>
<div>Leonardo Nunes</div>
</div>
</div>
</div>
</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>Stian Thorgersen <<a href="mailto:sthorger@redhat.com" target="_blank">sthorger@redhat.com</a>><br>
<span style="font-weight:bold">Reply-To: </span>"<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>" <<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>><br>
<span style="font-weight:bold">Date: </span>terça-feira, 16 de fevereiro de 2016 14:27<br>
<span style="font-weight:bold">To: </span>Leonardo Nunes <<a href="mailto:leo.nunes@gjccorp.com.br" target="_blank">leo.nunes@gjccorp.com.br</a>><br>
<span style="font-weight:bold">Cc: </span>Bruno Oliveira <<a href="mailto:bruno@abstractj.org" target="_blank">bruno@abstractj.org</a>>, "<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>" <<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [keycloak-user] Problems when using Javascript Adapter<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">Your HTML5 application should use the JavaScript adapter, not both as you are doing now. That is why you are getting a endless redirect loop as both adapters just keep trying to login.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 16 February 2016 at 13:23, LEONARDO NUNES <span dir="ltr">
<<a href="mailto:leo.nunes@gjccorp.com.br" target="_blank">leo.nunes@gjccorp.com.br</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:16px;font-family:Calibri,sans-serif">
<div>
<div>Bruno thanks for the replay.</div>
<div>I have tried the cors example application and it works fine.</div>
<div>When I configure my application to login the way cors example application does, it works also.</div>
<div><br>
</div>
<div>The problem I see is that it calls the init method with the login-required, and this causes every page load to login again.</div>
<div>I have an event listener adapter that sends a request to our statistics server after every login, when I use the onLoad: 'login-required' then on every page load the listener for login is called.</div>
<div>keycloakAuth.init({ onLoad: 'login-required' })</div>
<div><br>
</div>
<div>One thing got confused is, when I use the Javascript Adapter, then I don't have to configure keycloak at the web.xml?</div>
<div>Or can I still configure at the web.xml, define the restricted urls and also use the Javascript Adapter?</div>
<div><br>
</div>
<div>I might be using the Javascript Adapter not the way it was designed to be used.</div>
<span><font color="#888888">
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>-- </div>
<div>Leonardo Nunes</div>
</div>
<div><br>
</div>
<div></div>
</div>
</font></span></div>
<span><font color="#888888">
<div><br>
</div>
</font></span><span><span><font color="#888888">
<div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>Bruno Oliveira <<a href="mailto:bruno@abstractj.org" target="_blank">bruno@abstractj.org</a>><br>
<span style="font-weight:bold">Date: </span>terça-feira, 16 de fevereiro de 2016 09:49<br>
<span style="font-weight:bold">To: </span>Leonardo Nunes <<a href="mailto:leo.nunes@gjccorp.com.br" target="_blank">leo.nunes@gjccorp.com.br</a>>, "<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>" <<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [keycloak-user] Problems when using Javascript Adapter<br>
</div>
</font></span>
<div>
<div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">I believe that your issue is related to CORS, take a look at the examples <a href="https://github.com/keycloak/keycloak/tree/master/examples/cors" target="_blank">https://github.com/keycloak/keycloak/tree/master/examples/cors</a> and the documentation
as well <a href="http://keycloak.github.io/docs/userguide/keycloak-server/html/cors.html" target="_blank">http://keycloak.github.io/docs/userguide/keycloak-server/html/cors.html</a>.
<div><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Feb 16, 2016 at 9:44 AM LEONARDO NUNES <<a href="mailto:leo.nunes@gjccorp.com.br" target="_blank">leo.nunes@gjccorp.com.br</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:16px;font-family:Calibri,sans-serif">
<div>Hi, I'm having a problem when using the Javascript Adapter with an application deployed on Tomcat 7 at localhost:8088 and using Keycloak 1.8.0.CR3 on localhost:8080.</div>
<div><br>
</div>
<div>I get the following error at the browser console when trying to call the keycloak.loadUserProfile() method.</div>
<div>XMLHttpRequest cannot load <a href="http://localhost:8080/auth/realms/demo/account" target="_blank">
http://localhost:8080/auth/realms/demo/account</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:8088" target="_blank">http://localhost:8088</a>' is therefore not allowed access. The response
had HTTP status code 403.</div>
<div><br>
</div>
<div>And this when I try to call keycloak.loadUserProfile() method.</div>
<div>XMLHttpRequest cannot load <a href="http://localhost:8080/auth/realms/demo/protocol/openid-connect/userinfo" target="_blank">
http://localhost:8080/auth/realms/demo/protocol/openid-connect/userinfo</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:8088" target="_blank">http://localhost:8088</a>' is therefore not allowed
access. The response had HTTP status code 403.</div>
<div><br>
</div>
<div>Details:</div>
<div><br>
</div>
<div>- If I don't login using keycloak.login() and just navigate to a restricted page configured at the web.xml and login, after i'm redirected to the restricted page if I try to call keycloak.loadUserProfile() I get the same error.</div>
<div>- If I login using keycloak.login() and then call keycloak.loadUserProfile() or keycloak.loadUserProfile() it works.</div>
<div>- If I navigate to another page and try to call keycloak.loadUserProfile() or keycloak.loadUserProfile() I get the same error.</div>
<div>- It only works right after I login, if I navigate to another page it won't work anymore.</div>
<div><br>
</div>
<div>This is my keycloak.json file</div>
<div>
<div>{</div>
<div> "realm": "demo",</div>
<div> "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",</div>
<div> "auth-server-url": "<a href="http://localhost:8080/auth" target="_blank">http://localhost:8080/auth</a>",</div>
<div> "ssl-required": "external",</div>
<div> "resource": "accounts-teste",</div>
<div> "public-client": true,</div>
<div> "enable-cors": true</div>
<div>}</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>-- </div>
<div>Leonardo Nunes</div>
</div>
</div>
<hr style="min-height:1px;color:#c4c4c4">
<div style="font-family:Arial;color:#848484;font-size:11px"><i>Esta mensagem pode conter informação confidencial e/ou privilegiada. Se você não for o destinatário ou a pessoa autorizada a receber esta mensagem, não poderá usar, copiar ou divulgar as informações
nela contidas ou tomar qualquer ação baseada nessas informações. Se você recebeu esta mensagem por engano, por favor avise imediatamente o remetente, respondendo o e-mail e em seguida apague-o. Agradecemos sua cooperação.
<br>
<br>
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have
received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation<i></i></i></div>
</div>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></blockquote>
</div>
</div>
</div>
</div>
</div>
</span></div>
<br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span>
</div>
<br>_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br></blockquote></div>