title: Firebase: How to generate access token from username and password on the server?
body: <p>I have a Firebase app and I'm integrating Zapier. They require users to authenticate with my app through their form.</p>
  
  <p>The way it works is that Zapier will request email and password from a user and send it to my endpoint to get an access token and to use it with any further requests.</p>
  
  <p>I can't quite figure out how to generate an access token from username and password on server (node js) since all the authentication methods live in the client SDK.</p>
  
  <p>So far I was hoping to authenticate user with the provided email/password, generate a custom token from their <code>uid</code> and send it back to Zapier. But I can't do that since there is no <code>signInWithEmailAndPassword</code> or similar methods in the server SDK.</p>
  
  <p>I know I can fetch user by email, but how can I check the password than, since the corresponding methods are again only available in the client SDK?</p>
  
  <p>So far I've got the following code:</p>
  
  <pre><code>const rp = require('request-promise');
  
  app.post('/api/integrations/zapier/auth', (req, res) =&gt; {
          let data = req.body
          admin.auth().signInWithEmailAndPassword(data.email, data.password) // &lt;- this method doesn't exist in the server sdk
              .then(response =&gt; admin.auth().createCustomToken(response.user.id))
              .then(customToken =&gt; rp({
                  url: `https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=${config.apiKey}`,
                  method: 'POST',
                  body: {
                      token: customToken,
                      returnSecureToken: true
                  },
                  json: true,
              }))
              .then(idToken =&gt; {
                  res.send({
                      accessToken: idToken,
                      filed: data.email
                  });
              }).catch(error =&gt; res.status(500).send(error));
      })
  </code></pre>