title: In firebase - How to generate an idToken on the server for testing purposes?
body: <p>I want to test a a cloud function that creates users. </p>
  
  <p>In normal cases, inside the browser i generate an <code>idToken</code> and i send it to server via headers: <code>Authorization : Bearer etcIdToken</code></p>
  
  <p>But I want to test this function without the browser. In my mocha tests i have: </p>
  
  <pre><code>before(done =&gt; {
     firebase = require firebase.. -- this is suppose to be like the browser lib.
     admin = require admin.. 
  
      idToken = null;
      uid = "AY8HrgYIeuQswolbLl53pjdJw8b2";
      admin.auth()
          .createCustomToken(uid)               -- admin creates a customToken
          .then(customToken =&gt; {
              return firebase.auth()            -- this is like browser code. customToken get's passed to the browser.
                  .signInWithCustomToken(customToken)     -- browser signs in.
                  .then(signedInUser =&gt; firebase.auth()             -- now i want to get an idToken. But this gives me an error.
                      .currentUser.getIdToken())
          })
          .then(idToken_ =&gt; {
              idToken = idToken_
              done();
          })
          .catch(err =&gt; done(err));
  })
  </code></pre>
  
  <p>The error i'm getting is: </p>
  
  <p><code>firebase.auth(...).currentUser.getIdToken is not a function</code> - <a href="https://firebase.google.com/docs/auth/admin/verify-id-tokens" rel="noreferrer">getting the idToken like this works on client -  and is documented here.</a></p>
  
  <p>I tried directly with <code>signedInUser.getIdToken()</code>. Same problem:</p>
  
  <p><code>signedInUser.getIdToken is not a function</code> - not documented. just a test.</p>
  
  <p>I think this is because <code>firebase</code> object is not intended for <code>node.js</code> use like i'm doing here. When signing in - stuff get's saved in browser local storage - and maybe this is why. </p>
  
  <p>But the question still remains. How can i get an idToken inside node.js in order to be able to test:</p>
  
  <pre><code>return chai.request(myFunctions.manageUsers)
      .post("/create")
      .set("Authorization", "Bearer " + idToken)   --- i need the idToken here -  like would be if i'm getting it from the browser.
      .send({
            displayName: "jony",
            email: "jony@gmail.com",
            password: "123456"
      })
  </code></pre>
  
  <p><strong>am I approaching this wrong? I know that if i can get the <code>idToken</code> it will work. Do i rely need the browser for this? Thanks :)</strong></p>