title: Error: Firebase ID token has expired
body: <p>On my server I'm seeing these errors when using firebase admin sdk <code>.verifyIdToken()</code></p>
  <blockquote>
  <p>Firebase ID token has expired. Get a fresh token from your client app and try again</p>
  <p>Firebase ID token has &quot;kid&quot; claim which does not correspond to a known public key. Most likely the ID token is expired, so get a fresh token from your client app and try again. See <a href="https://firebase.google.com/docs/auth/admin/verify-id-tokens" rel="noreferrer">https://firebase.google.com/docs/auth/admin/verify-id-tokens</a> for details on how to retrieve an ID token.</p>
  </blockquote>
  <p>On the client side I'm doing this before every request between browser &lt;&gt; server:</p>
  <pre><code>firebase.auth().currentUser.getIdToken()
  </code></pre>
  <p>It's my understanding from reading the docs that this function will get a valid, non-expired token because the SDK in the background will refresh itself as-needed. Optionally, I can pass in <code>true</code> to this function to force a refresh.</p>
  <p>Why does this <code>getIdToken()</code> function seem to be sending expired tokens to my backend?</p>
  <p>It seems like to resolve this my options are:</p>
  <ol>
  <li>Pass in <code>true</code> to force refresh every time I call getIdToken(). This is needlessly expensive because it will add the overhead of a whole round-trip network request from the browser &lt;&gt; firebase before the request from browser &lt;&gt; my server</li>
  <li>call <code>getIdToken()</code> the way I am now - decode the token manually on the client side, check the expiration, if it is expired then call <code>getIdToken(true)</code> again to force a refresh and send that newly refreshed token to my server</li>
  </ol>
  <p>Is number 2 the recommended/expected way to deal with this? It seems like something is wrong here...</p>