title: Firebase verifyIdToken Error: Decoding Firebase ID token failed.
body: <p>I am trying to setup an Android app communicating with a NodeJS REST API that communicates with Firebase but it seems the firebase token does not work for me. </p>
  
  <p>I'm running a local nodejs server and an Android simulation locally now to test it out and here is how it looks:</p>
  
  <p>Android method:</p>
  
  <pre><code>@Override
  public void onNewToken(String token) {
      Log.i(TAG, "Refreshed token: " + token);
      postRegistrationToken(token);
  }
  </code></pre>
  
  <p>This correctly generates and sends to the REST API. </p>
  
  <p>Log shows: </p>
  
  <pre><code>Refreshed token: "MY_TOKEN_STRING"
  </code></pre>
  
  <p>in NodeJS:</p>
  
  <pre><code>app.post('/api/token/get', (req, res) =&gt; {
  const token = req.body.registrationToken;
  LOG.info(`Acquired token: ${token}`);
  admin.auth().verifyIdToken(token)
      .then((decodedToken) =&gt; {
          LOG.info(`Successfully validated registrationToken ${token}`);
          //stuff
      })
      .catch((err) =&gt; {
          LOG.error(err)
      });
  });
  </code></pre>
  
  <p>The verifyIdToken fails but the token is the same that was generated in the Android client: </p>
  
  <pre><code>Acquired token: "MY_TOKEN_STRING"
  Error: Decoding Firebase ID token failed.
   Make sure you passed the entire string JWT which represents an ID token.
   See https://firebase.google.com/docs/auth/admin/verify-id-tokens for details on how to retrieve an ID token.
  </code></pre>
  
  <p>I tried to validate the token in a JWT validator website like <a href="https://www.jsonwebtoken.io/" rel="noreferrer">https://www.jsonwebtoken.io/</a> but they say it's an invalid signature. </p>
  
  <p>Am I missing something or what could be wrong? </p>