‫Hello, my friends, and welcome back.
‫In this video we will add Firebase authentication to our project.
‫Open Firebase, go to documents and select authentication here or you can from the left side bar, you
‫can choose it.
‫Click on introduction and we scroll down to add the dependency for authentication.
‫You can add authentication for Google accounts, sign in with Apple, Facebook, Twitter, GitHub and
‫others.
‫Okay.
‫Also, you can use the email and password based authentication for this project.
‫I will use the the email and password because it's the most, the most complex thing, which is the
‫email and password.
‫The others, the GitHub, Facebook, Google, they are APIs and they and the SDKs are very simple.
‫Now I will add the authentication dependency to our project.
‫Copy it.
‫I will go to Gradle.
‫And I will add it to the Gradle project here.
‫Here is the authentication dependency.
‫Click sync now and by the way, I will use our friend build.
‫Build features.
‫I will add the data binding.
‫Equal to true.
‫This is our friend data binding.
‫Okay, so.
‫This is how we add the authentication.
‫Let's go back to the the, the console.
‫I will use the build click on authentication and here is the authentication dashboard.
‫Authenticate and manage users from variety of providers without server side code.
‫Click on Get Started.
‫And here we need to get started with first signing a sign in method.
‫You can see all these sign in methods.
‫I will click on email and password, click enable and click Save.
‫You can see that the sign in provider is the email and password.
‫You can see the users sign in methods, templates, usage settings and so on.
‫Let's move to the authenticate the documentations.
‫The first step is to create the Firebase auth.
‫Here is the object.
‫I will start with the sign up here late in var oath and initialize the firebase authentication here
‫I will click alt plus enter to import the package of Firebase and authentication.
‫Okay.
‫You can see here is the Firebase authentication.
‫Now we need to start checking for the current user.
‫So this is the Onstart method to check if the user is signed in or which is non null and update the
‫UI accordingly.
‫So outside the onstart oncreate.
‫I will use this method.
‫Okay now.
‫In order to create the others how to to manage the oath and create user with email and password.
‫I will copy this.
‫Method auth dot create user with email and password.
‫This is when I need to execute this method.
‫When the user click on this button, sign up.
‫So I will go up.
‫Also I will use late initiate var binding which is for the activity sign up.
‫Actor.
‫50.
‫Sign up.
‫Oops.
‫I have missed to add the layout tag here, so I will add layout tag to it and.
‫And I will.
‫To copy this.
‫Scroll down to here and add the ending and the closing tag here.
‫Activity.
‫Sign up binding and this binding.
‫Binding equal.
‫Util.
‫Data binding util dot.
‫Set content to view.
‫So this and our dot layout dot activity sign up.
‫I will remove this.
‫And this is for the binding.
‫Now I will use the binding to add.
‫The.
‫This is if I click on it its activity or account sign up button.
‫So OCC sign up button set on click Listener.
‫Here I'm setting and calling create.
‫User.
‫Alt+ enter to create this function and I will paste the code from here and I will lecture it.
‫Okay.
‫So.
‫What does this mean?
‫Authentication that create user with email and password.
‫I need to pass the email and password so this create user will took two parameters the email and password.
‫From where I need to get them.
‫I need to get them from the email and password edit text.
‫So for that I will use val the email equal to.
‫It's of type string.
‫Binding.
‫Dot.
‫This is the the email.
‫Email underscore.
‫Create.
‫Email.
‫Create.
‫And.
‫This is the password.
‫So I need the email and the password.
‫Dot.
‫Get text.
‫Thought to string and val password.
‫Equal to binding dot password dot text dot to string.
‫Okay.
‫I passed them here.
‫If task is successful, I will look and here I will add tag create user successfully and I need to call
‫update UI.
‫Then I need.
‫To check for else if sign in is failed, I need to log in with to log the tag with tag and update the
‫UI.
‫Okay, so till now we need to create reload and update UI functions.