<div dir="ltr">So here is my branch with some changes (but - disclaimer-  it&#39;s still not working but will maybe help to make progress) : <a href="https://github.com/sebastienblanc/aerogear-unified-push-server/tree/keycloak_angular_integration">https://github.com/sebastienblanc/aerogear-unified-push-server/tree/keycloak_angular_integration</a><div>
<br></div><div>The problem is now on the server side,   this give a NPE : </div><div><a href="https://github.com/sebastienblanc/aerogear-unified-push-server/blob/keycloak_angular_integration/jaxrs/src/main/java/org/jboss/aerogear/unifiedpush/rest/registry/applications/PushApplicationEndpoint.java#L78">https://github.com/sebastienblanc/aerogear-unified-push-server/blob/keycloak_angular_integration/jaxrs/src/main/java/org/jboss/aerogear/unifiedpush/rest/registry/applications/PushApplicationEndpoint.java#L78</a><br>
</div><div><br></div><div>So basically, in the request we don&#39;t have the UserPrincipal but from the client I can see an Authorization header : </div><div><br></div><div><ol class="" style="margin:0px;min-width:100%;list-style-type:none;color:rgb(48,57,66);font-family:Ubuntu,Arial,sans-serif;font-size:12px;padding:2px 6px!important">
<li title="" style="padding:0px 0px 0px 14px;margin-top:1px;word-wrap:break-word;white-space:nowrap"><span class="" style="font-family:&#39;dejavu sans mono&#39;,monospace;white-space:pre-wrap;display:inline;margin-right:100px;word-break:break-all;margin-top:1px;font-size:11px!important">GET /ag-push/rest/applications HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
Accept: application/json, text/plain, */*
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIxNTk5MzBmNi05NDI4LTQxM2EtYTExZi00MjA3MzY5ZTMyOGYiLCJleHAiOjE0MDIyMjI2MDEsIm5iZiI6MCwiaWF0IjoxNDAyMjE5NjAxLCJpc3MiOiJhZXJvZ2VhciIsImF1ZCI6ImFlcm9nZWFyIiwic3ViIjoiOWFlOTE3ZTItMTViZi00MzhmLThlYzctMGE5YzBkM2RkNzlhIiwiYXpwIjoidW5pZmllZC1wdXNoLXNlcnZlciIsInByZWZlcnJlZF91c2VybmFtZSI6ImFkbWluIiwic2Vzc2lvbl9zdGF0ZSI6IjJmNzkzNjQ2LWFmYjUtNDdkOC1hMmNmLWM1MDJjNThmMTQzMiIsImFsbG93ZWQtb3JpZ2lucyI6W10sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJhZG1pbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7fX0.Vk8_RJOnzh1tvWxHCLu5WTyOdy84LU1QwclCq4NRTqDL-82B-X1CuJVVnxr3abqgdRZbtvVIgEDeQvnYXLKYmLSCsT-PtJl54AQc72GRRDplyVkaGlw1Vcg-eNGwnyy6jnYusmumuf_24H0DaxXWITXi-GKRoW4cVn7lEwqgF_k
Referer: <a href="http://localhost:8080/ag-push/?redirect_fragment=/main&amp;code=eyJhbGciOiJSUzI1NiJ9.ZGE3ZTYzNWEtZTYxYi00Y2ViLTg1OWMtMDBkMDU2YjlkMjdmMTQwMjIxOTYwMTAzMg.aQ9hBljDqFchGzkblFrYQ2E_Ax8kh-P4r7Ctz8oPx4dCKVpRM0zmxYkpC_0ALEzPHXS6AKv58MQTXM55_8yUxk15AC9-foCvrYZvPrFqNL4c_GQm5P4KivP6t-RNS0pg63zziM3QNLq9aOVeoFnm5fZU5i0ZGvzT8edzFHmYlds&amp;state=e2918ebe-e5b8-46d5-823e-e727b2ea18bd
Accept-Encoding">http://localhost:8080/ag-push/?redirect_fragment=/main&amp;code=eyJhbGciOiJSUzI1NiJ9.ZGE3ZTYzNWEtZTYxYi00Y2ViLTg1OWMtMDBkMDU2YjlkMjdmMTQwMjIxOTYwMTAzMg.aQ9hBljDqFchGzkblFrYQ2E_Ax8kh-P4r7Ctz8oPx4dCKVpRM0zmxYkpC_0ALEzPHXS6AKv58MQTXM55_8yUxk15AC9-foCvrYZvPrFqNL4c_GQm5P4KivP6t-RNS0pg63zziM3QNLq9aOVeoFnm5fZU5i0ZGvzT8edzFHmYlds&amp;state=e2918ebe-e5b8-46d5-823e-e727b2ea18bd
Accept-Encoding</a>: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,fr;q=0.6
Cookie: JSESSIONID=nBxjj-qL3YRjCtxKKyMutHPQ.undefined</span></li></ol><div><font color="#303942" face="dejavu sans mono, monospace"><span style="font-size:11.199999809265137px;white-space:pre-wrap"><br></span></font></div>
</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jun 7, 2014 at 11:29 AM, Sebastien Blanc <span dir="ltr">&lt;<a href="mailto:scm.blanc@gmail.com" target="_blank">scm.blanc@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi my friend ! <div><br><div>Just to let you know I started to look at your branch and indeed you better not be epileptic to survive the crazy reloads ;)</div>
<div>I have nothing to push right now but I have some ideas : </div>
<div><br></div><div>* Like you mention, the redirect and main route broke the stuff. So, I think we should remove that and do the initial redirect in the success callback of the keycloakAuth.init call. I have a local branch where I manage to do that, but it&#39;s really hacky and I face another issue , the first next REST call fails because there are not auth info. But ! This is there where we have to introduce the Auth interceptor like here <a href="https://github.com/keycloak/keycloak/blob/master/examples/demo-template/angular-product-app/src/main/webapp/js/app.js#L43-L60" target="_blank">https://github.com/keycloak/keycloak/blob/master/examples/demo-template/angular-product-app/src/main/webapp/js/app.js#L43-L60</a></div>

<div><br></div><div>I think based on this, we should be able to find a solution. I will try to push my work ASAP and maybe some dudes for KC could give us some hints as well.</div><div><br></div><div>Have a good weekend ! </div>

<div><br></div><div>sebi </div><div><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 6, 2014 at 6:05 PM, Bruno Oliveira <span dir="ltr">&lt;<a href="mailto:bruno@abstractj.org" target="_blank">bruno@abstractj.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Good morning,<br>
<br>
I&#39;m struggling to integrate Keycloak.js with our admin-ui. Everything<br>
works perfectly well out of admin-ui with UPS and Angular.js as you<br>
might notice here:<br>
<a href="https://github.com/abstractj/aerogear-unifiedpush-server/tree/keycloak-angular" target="_blank">https://github.com/abstractj/aerogear-unifiedpush-server/tree/keycloak-angular</a><br>
<br>
The issue lies when I enable the routes related with redirect and<br>
MainController:<br>
<a href="https://github.com/abstractj/aerogear-unifiedpush-server/tree/keycloak_angular_integration" target="_blank">https://github.com/abstractj/aerogear-unifiedpush-server/tree/keycloak_angular_integration</a>.<br>
Just open <a href="http://localhost:8080/ag-push" target="_blank">http://localhost:8080/ag-push</a> and watch your browser reload<br>
like crazy. When the main route and redirect are disable, everything goes<br>
well:<br>
<a href="https://github.com/abstractj/aerogear-unifiedpush-server/commit/dd9438c6503061fba8aa0e0d77973971888e9379" target="_blank">https://github.com/abstractj/aerogear-unifiedpush-server/commit/dd9438c6503061fba8aa0e0d77973971888e9379</a><br>


<br>
<br>
At first glance it doesn&#39;t sound to be a problem on KC.js, once already works with Angular.js:<br>
<a href="https://github.com/keycloak/keycloak/tree/master/examples/demo-template/angular-product-app" target="_blank">https://github.com/keycloak/keycloak/tree/master/examples/demo-template/angular-product-app</a>.<br>
<br>
If you have any idea, help is appreciated.<br>
<br>
--<br>
<br>
abstractj<br>
_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>