Firebase: Google Sign-In Authentication
As we have discussed earlier, Firebase provides different types of Authentication methods. In our previous section, we learned how authentication is done using Firebase UI and Firebase SDK. In this section, we will learn another method, i.e., Google Sign-in Authentication. It is pretty easy to do.
Starting steps are the same as we have done with other authentication methods, which are as follows:
Apart from firebase auth and core libraries, we have to add google play services auth in app.gradle file
In the next step, we have to enable the Google sign-in method in Firebase console. We also have to add a project supporting email.
Just like our previous method, we have to set SHA-1 and SHA-256 keys.
In the next step, we will create the layout file that contains three buttons Google sign-in, sign-out, and sign-out and disconnect. The activity layout will look like:
Now, we will modify our MainActivity.java file to perform the Google sign-in authentication in the following way: