[keycloak-user] what to do after storing the token with javascript

Juan Diego juandiego83 at gmail.com
Tue Jun 23 14:06:12 EDT 2015


Hi,

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.

1)
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
console.log(keycloak)

2)
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.

Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20150623/337913b7/attachment.html 


More information about the keycloak-user mailing list