Javatpoint Logo
Javatpoint Logo

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:

  1. Creating an Android project.
  2. Creating a Firebase project.
  3. Adding Firebase to the Android project or application, either manually or Firebase Assistance.
  4. Adding the required libraries and JSON files.

Step 1:

Apart from firebase auth and core libraries, we have to add google play services auth in app.gradle file

Firebase Google Sign in Authentication

Step 2:

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.

Firebase Google Sign in Authentication

Step 3:

Just like our previous method, we have to set SHA-1 and SHA-256 keys.

Firebase Google Sign in Authentication

Step 4:

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:

Firebase Google Sign in Authentication

Step 5:

Now, we will modify our MainActivity.java file to perform the Google sign-in authentication in the following way:


Firebase Google Sign in Authentication
Firebase Google Sign in Authentication






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA