title: Keycloak javascript - Store the keycloak object
body: <p><strong>Goal</strong></p>
  
  <p>I am implementing Keycloak in an Angular2 project as my authentication service. For this, I use the javascript adapter. </p>
  
  <p><strong>Problem</strong></p>
  
  <p>I initialize the Keycloak object in the main.ts. A login is not directly required. During implementation, I faced a problem. When a page refresh occurred, a new Keycloak object is created which doesn't hold the original status (loginstatus, token etc.). 
  I tried to save the Keycloak object to the localStorage. When I get (after JSON stringify and parse) the object, the object isn't recognized as a Keycloak object. </p>
  
  <p><strong>Current workaround</strong></p>
  
  <p>When logging in, I save an 'authenticated' boolean to the localStorage. I do a check in the main.ts if that 'authenticated' value is true. Then do a log in (after init) when a page refresh occurs. This is resulting in a double page refresh because the user gets redirected to Keycloak and is directly</p>
  
  <p><strong>Question</strong></p>
  
  <p>Is there a way to store the Keycloak object? Or is it possible to check if the user is already logged in when a new object is created?</p>