title: How to prevent Firebase anonymous user token from expiring
body: <p>I'm using anonymous authentication is a Firebase app. I just noticed that I have over 100 anonymous users now registered even though all I've been doing is testing the app. It looks like the expiration time for the user token is quite short, and as soon as it expires the next login causes a new user to be created.</p>
  
  <p>What is the best way to avoid this? I could presumably refresh the user's token but I'm not sure how to this since in <code>onAuthStateChange</code> the <code>user</code> parameter is <code>null</code> if the user has expired.</p>
  
  <p>Or should I changed the expiration time? If so, how do I do this? I found some instructions for doing so in the old Firebase docs but can't see how to do it in the latest version.</p>
  
  <p>UPDATE: Currently I am initializing the app and authenticating the (anonymous) user like so:</p>
  
  <pre><code>firebase.initializeApp(FIREBASE_CONFIG);
  
  firebase.auth().onAuthStateChanged(user =&gt; {
    if (!user) {
      firebase.auth().signInAnonymously().catch(error =&gt; {
        console.error('Failed to authenticate with Firebase', error);
      });
    }
  });
  </code></pre>