This article is about creating an authentication for your android applications based on email and password using Firebase. The entire application is built using Kotlin
Select Tools — > Firebase to get access to the firebase assistant panel in your Android Studio.
Make sure to sign in to your gmail account from Android Studio to get access to the Google’s Firebase and Cloud functions from your android studio IDE.
Make sure to select the email and authentication option from your firebase assistant panel.
Now you can add the following authentication dependencies to the project module by selecting accept changes.
implementation 'com.google.gms.google-services'
implementation 'com.google.firebase:firebase-auth:11.0.4'
These lines will be added to the app.gradle file and the gradle files will be synced.
signInWithEmailAndPassword (email, password)
This method enables user to login into their firebase accounts using email and password.
Now go to the Firebase assistant panel and select Realtime database option.
implementation 'com.google.firebase:firebase-database:11.0.4
Now your realtime database dependencies are added to your project module and are locally available for use.
createUserWithEmailAndPassword (email, password)
This method enables user to register into their firebase accounts using email and password.
DatabaseReference (mDatabase) is created. Now the mDatabase instance and reference from the firebase console has been initialized. Now add the name value to the database by pointing the mDatabase to the “Name” child. Now use the setValue () function to set the value of the name to that database child [setValue(name)].
Now set the database reference (mDatabase) for this activity pointing to the name child and attach an addValueEventListener() to listen to the datasnapshot from the firebase database console to fetch the name value from the database.
Now, to log out of the account use signOut () from Firebase Authentication to log out of your firebase account.
Before deploying your application make sure to enable the Email/Password feature under Sign in providers tab from Authentication tab on firebase console.
Thanks for reading this article. Hope this helps you. Make sure to share this article. With love Ashwin :)