When you go about to build an application, there are a ton of considerations to take into account. And those are all mainly concerned with the client part. When you start to think about the server of your application, things can get pretty complicated. One option to alleviate some of that pressure is to use Firebase, in particular, two features from Firebase:
We will show in this article :
If all of this might seem like a simple task, it isn’t. There is obviously a lot of setting up to do and handling various configurations, but here are also some pitfalls one would benefit from that will help save time and frustration.
Learn from my mistakes.
If you want to skip over all of the explanations, you can head over to the bottom of the article and see the entire source code there through the links.
Our application will consist of both a front-end side and a back-end side. From the front-end perspective, there will be a login/signup page and another page that will fetch/send random data to our database. We will be using Firebase Authentication here to validate registered users. There are several ways to authenticate users:
In our application, we will use the email and password option as it is the more straightforward approach and, in most cases, the more common solution.
This authentication will happen in our client and there will be no need for any communication to our back end for this task.
To make requests to the server, we will be using Retrofit2 by making GET requests. In these GET requests, we will be sending the data that needs to be updated alongside a token (more about the token in the Server section).
From the back-end side, our server is in charge of accepting requests from users using our application to either fetch/save/delete data (or CRUD). To be able to let authenticated users access the database, we will need to use Firebase’s Admin SDK. This framework will give us access to an API to verify authenticated users and pass requests to our database. We will be saving users data using Firebase’s Realtime Database. After all is done on the back-end side, we will be deploying it via Heroku.
#firebase #kotlin #mobile #authentication