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:
- Could Messaging
- Real-time Database
- 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.
- Visit Firebase website https://firebase.google.com/ and create a free developer account.https://firebase.google.com/ and create a free developer account.
- 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.
- 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.
- 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.
- We have created a Firebase project and integrated our app via package name, the next step is to enable Google login in Firebase.
- 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.
- Create a new project in Android Studio and select default activity and proceed.
- In the project details section, enter the same name as the one you used in Firebase for the package name.
- 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” />”
- 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.
- The next step is to add Firebase dependency to your app. Just open build.gradle file and add the following lines
apply plugin: ‘com.google.gms.google-services’
To summarize these are the list of steps required.
- Create free account in Firebase and create a new project
- Add Package name for linking purpose
- Enable Google Login and downloaded google-services.JSON file
- Create a new android project in Android Studio using the same package name
- Add the google-services.JSON file to the project app folder.
- Add necessary permissions and dependencies to your project in build.gradle.
- 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
- 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.