[keycloak-user] Initializing keycloak.js without extra request for keycloak.json?

Stian Thorgersen sthorger at redhat.com
Fri Apr 15 01:45:59 EDT 2016


You don't need to pass in the whole keycloak.json like this, to initialize
it without the request for keycloak.json just do:

  new Keycloak({
    realm: "myReam",
    clientId: "myClientId"
  }

That's it.


On 14 April 2016 at 21:59, Michael Clayton <mclayton at redhat.com> wrote:

> Hi all,
>
> I'm integrating keycloak.js with the Red Hat Customer Portal and have a
> question about passing a configuration object into the Keycloak()
> constructor.
>
> At the point where I call Keycloak(), I'm attempting to avoid waiting
> for the keycloak.json HTTP GET by inlining keycloak.json during a build
> step.  By example, my build now produces this:
>
>     var keycloak = new Keycloak({
>         "realm" : "myRealm",
>         "realm-public-key" : "myPublicKey",
>         "auth-server-url" : "https://keycloak.me/auth",
>         "ssl-required" : "external",
>         "resource" : "myClientId",
>         "public-client" : true,
>         "token-store": "cookie"
>     });
>
> I was hoping this would Just Work, but I quickly discovered that some of
> the properties are "renamed" after the HTTP request:
>
>     kc.authServerUrl = config['auth-server-url'];
>     kc.realm = config['realm'];
>     kc.clientId = config['resource'];
>     kc.clientSecret = (config['credentials'] || {})['secret'];
>
> And thus my setup doesn't work because "clientId" doesn't exist inside
> keycloak.json.
>
> My question is: would I be foolish to rename the properties inside
> keycloak.json so that the JSON can be passed directly into the Keycloak
> constructor?  For example, "resource" becomes "clientId" and
> "auth-server-url" becomes "authServerUrl".
>
> It would be really convenient if I could give keycloak.js the contents
> of keycloak.json without having to fret about where it came from (AJAX
> or hardcoded or build-inlined).  If others would like that feature too,
> I'd happily put together a contribution.
>
> Thanks for any advice!
>
> --
> Michael Clayton
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160415/b390a15a/attachment.html 


More information about the keycloak-user mailing list