We need to create a Firebase project, but we will be using the Authentication feature instead of the Realtime database now. If you already have a Firebase project set up, you can use the Authentication feature for that project.
Sign-in providers
Firebase offers a range of sign-in providers. You can select any one from these.
Here, we will be using the generic authentication flow using the Email/Password sign-in provider. We need to enable this sign-in provider by clicking on it and changing the configuration to enable it. We are using this sign-in provider to mimic our own Authentication API.
Firebase REST API
Registering New Users
With our Firebase authentication set up, we can now add users to our application, and give them appropriate authentication tokens to access protected resources within our web app.
I'll be using a custom hook to set up a fetch request to the Firebase API to add new users via authentication. Here is the custom hook:
Now, we need to connect the REST API to handle adding new users and allowing existing users to log in to our web application. This can be done by referring to the docs .
To use the Sign-up REST API from Firebase, we need to use .
After successfully registering a user to our Firebase back-end API, it is time we add the logic to allow already registered users to gain access to the protected resources in our app. We would need to refer .