Google SignIn

Firebase is a Google-owned platform for developing both Mobile and Web applications. It provides the necessary tools and infrastructure for developers to create apps. The list of services provided by Firebase are:

  • Analytics
  • Could Messaging
  • Authentication
  • Real-time Database
  • Storage
  • Hosting
  • Test lab for Android
  • Crash Reporting

We will be looking Authentication service using which we will be creating Google Signin for our apps. Now a day’s most of the apps required login functionality and most preferred login method is Social Login. Login with Facebook, Login with Google, etc. We will be setting up Login with Google using Firebase Google Signin.

Firebase Module

  1. Visit Firebase website https://firebase.google.com/ and create a free developer account.https://firebase.google.com/ and create a free developer account.
  2. Create a New Project to get started. Please provide a suitable name for your project and also select your country and go to next step.
  3. In the subsequent screen, select “Add Firebase to your android app”. Add your package details along with Debug Signing Certificate SHA-1 key. To add Google Login, integrating your SHA-1 key is compulsory.
  4. Now a file named “google-services.json” will be downloaded. Save it to your local system, we need to add this to your Android app later.
  5. We have created a Firebase project and integrated our app via package name, the next step is to enable Google login in Firebase.
  6. Click on the Auth Menu -> SIGN-IN METHOD. In this screen, select Google and enable the same.

We have created a free account, added a project and integrated it with our app package name and enabled Google Login. Now we need to create our android app and add Firebase project to it.

Android Module

  1. Create a new project in Android Studio and select default activity and proceed.
  2. In the project details section, enter the same name as the one you used in Firebase for the package name.
  3. For Google Signin to work, your app needs to access the internet. To give internet permission to your app, open AndroidManifest.XML file and add the following line “<uses-permission android:name=”android.permission.INTERNET” />”
  4. Now we need to add the google-services.JSON file which was downloaded from Firebase project to our app. Just copy and paste the file to your Android Studio’s Project app folder.
  5. The next step is to add Firebase dependency to your app. Just open build.gradle file and add the following lines

classpath ‘com.google.gms:google-services:3.0.0’

apply plugin: ‘com.google.gms.google-services’

To summarize these are the list of steps required.

  1. Create free account in Firebase and create a new project
  2. Add Package name for linking purpose
  3. Enable Google Login and downloaded google-services.JSON file
  4. Create a new android project in Android Studio using the same package name
  5. Add the google-services.JSON file to the project app folder.
  6. Add necessary permissions and dependencies to your project in build.gradle.
  7. Now both the Firebase Google Module and the android app are ready and linked. Now you need to write the code to call Firebase APIs and accept Google Login in your app
  8. You can do both google login and also create new accounts using Firebase Google login.

This is an out-of-the-box option provided by Firebase which can be used by developers to easily enable Google Login for their app users.