<div dir="ltr">You don't need to pass in the whole keycloak.json like this, to initialize it without the request for keycloak.json just do:<div><br></div><div> new Keycloak({</div><div> realm: "myReam",</div><div> clientId: "myClientId"</div><div> }</div><div><br></div><div>That's it.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 April 2016 at 21:59, Michael Clayton <span dir="ltr"><<a href="mailto:mclayton@redhat.com" target="_blank">mclayton@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I'm integrating keycloak.js with the Red Hat Customer Portal and have a<br>
question about passing a configuration object into the Keycloak()<br>
constructor.<br>
<br>
At the point where I call Keycloak(), I'm attempting to avoid waiting<br>
for the keycloak.json HTTP GET by inlining keycloak.json during a build<br>
step. By example, my build now produces this:<br>
<br>
var keycloak = new Keycloak({<br>
"realm" : "myRealm",<br>
"realm-public-key" : "myPublicKey",<br>
"auth-server-url" : "<a href="https://keycloak.me/auth" rel="noreferrer" target="_blank">https://keycloak.me/auth</a>",<br>
"ssl-required" : "external",<br>
"resource" : "myClientId",<br>
"public-client" : true,<br>
"token-store": "cookie"<br>
});<br>
<br>
I was hoping this would Just Work, but I quickly discovered that some of<br>
the properties are "renamed" after the HTTP request:<br>
<br>
kc.authServerUrl = config['auth-server-url'];<br>
kc.realm = config['realm'];<br>
kc.clientId = config['resource'];<br>
kc.clientSecret = (config['credentials'] || {})['secret'];<br>
<br>
And thus my setup doesn't work because "clientId" doesn't exist inside<br>
keycloak.json.<br>
<br>
My question is: would I be foolish to rename the properties inside<br>
keycloak.json so that the JSON can be passed directly into the Keycloak<br>
constructor? For example, "resource" becomes "clientId" and<br>
"auth-server-url" becomes "authServerUrl".<br>
<br>
It would be really convenient if I could give keycloak.js the contents<br>
of keycloak.json without having to fret about where it came from (AJAX<br>
or hardcoded or build-inlined). If others would like that feature too,<br>
I'd happily put together a contribution.<br>
<br>
Thanks for any advice!<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Michael Clayton<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>
</font></span></blockquote></div><br></div>