How to prevent unauthenticated RESTful request in Firebase

If you’re using a Firebase functions “onCall” methods, you’re just able to use “req.auth” directly, when you have to return a response to user’s REST call.

But, if you’re using Firebase functions “onRequest” method, you need some additional work to make sure if the caller is a real user has been authenticated with Firebase Authentication.

Front side.