React + Auth0 + Firebase

I don’t believe you can use Auth0’s token directly with Firebase. You have to proxy that through an API which will use firebase-admin to issue a token.

We have a pretty nice example with Firebase and Auth0 in this blog post. If you skip everything about angular, you can actually see the code to issue the token in the Server section:

app.get('/auth/firebase', jwtCheck, (req, res) => {
    // Create UID from authenticated Auth0 user
    const uid = req.user.sub;
    // Mint token using Firebase Admin SDK
    firebaseAdmin.auth().createCustomToken(uid)
      .then(customToken => 
        // Response must be an object or Firebase errors
        res.json({firebaseToken: customToken})
      )
      .catch(err => 
        res.status(500).send({
          message: 'Something went wrong acquiring a Firebase token.',
          error: err
        })
      );
  });
1 Like