mposolda at redhat.com
Wed Jun 24 03:35:50 EDT 2015
You have option to pass the tokens from local storage to the 'init'
method of keycloak object. For example you can use something like:
Another option is to not store anything in localStorage, but instead
after refresh the page re-authenticate the user again. User won't need
to login again and provide username/password, because he should be
logged automatically due to SSO (unless session is expired). This is
what our admin console and examples are doing. Feel free to check them,
especially angular example:
On 23.6.2015 20:06, Juan Diego wrote:
> After my user logs I am saving the token to a localstorage. I am using
> angularjs by the way.
> So if my user refreshes the page they still have the session. As far
> as I can tell when you refresh the page, most of the info of the
> object keycloak is null, except for the realm and all the stuff you
> get form keycloak.json. Like if you have never logged.
> So I stored the token in my localStorage.
> I am thinking 3 options basically.
> Setting keycloak.token = localStorage.get("token"), and I was trying
> to look for a function in that object to retrieve all the other data,
> but I couldnt find any on the documentation and looking at my
> Storing the whole object keycloak in localstorage, the problem with
> this is that it will only store the properties and obviously not the
> functions, so I was thinking that I should manually set all the
> properties like this
> clientId= localStorageService.get('keycloak').clientId;
> idToken= localStorageService.get('keycloak').idToken;
> idTokenParsed= localStorageService.get('keycloak').idTokenParsed;
> realmAccess= localStorageService.get('keycloak').realmAccess;
> 3) Just check everything against the localstorage instead.
> But I wont be able to use the functions from the object keyclaok, like updateToken.
> I am kind of new to angular, as you can see too.
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the keycloak-user