title: Firebase: Sign in with a token
body: <h2>Firebase question</h2>
  
  <p>My goal is to keep a user signed in a desktop app made primarily with NodeJS</p>
  
  <ol>
  <li>User signs in</li>
  <li>Store some kind of token to sign user in later</li>
  <li>When user re-opens app, sign user in with that token if available</li>
  <li>Token can expire / be invalidated</li>
  </ol>
  
  <p>Currently, it seems Firebase relies on cookies of some sort. Is there a way to sign in a user without their email/password again?</p>
  
  <p>I am currently trying to use Firebase authentication as part of my Electron app where I cannot have the Firebase authentication code be part of a renderer process which would normally have access to browser-level storage.</p>
  
  <p>The ideal situation would be something like this that works:</p>
  
  <pre class="lang-js prettyprint-override"><code>    const auth_token = await user.getIdToken();
  
      firebase
        .auth()
        .signInWithCustomToken(auth_token) // But maybe some other method?
        .then((user) =&gt; {
          console.log(user);
        })
  
  </code></pre>
  
  <p>How would you do this in a NodeJS app that has no access to browser storage such that the user does not need to continuously login?</p>
  
  <p>Referencing this issue: <a href="https://stackoverflow.com/questions/55716608/persist-firebase-user-for-node-js-client-application">Persist Firebase user for Node.js client application</a></p>
  
  <p>fwiw, I don't wish to share these tokens with another application.</p>
  
  <h2>Electron question</h2>
  
  <p>A slightly different question: Can the main process in Electron store cookies that Firebase could access?</p>
  
  <p>Recently read this: <a href="https://github.com/firebase/firebase-js-sdk/issues/292" rel="nofollow noreferrer">https://github.com/firebase/firebase-js-sdk/issues/292</a></p>