Social Login
Learn step by step how to enable google, facebook or other login in firebase and replacing of google-services.json file in android studio.
We will start from the beginning with a new android studio project, same process is with your existing Android Studio Project.
First of all open Android studio in you system as administrator, check below screenshot for more info.
Now on main screen of Android Studio click on the New Project button as like below image
After that select an inbuilt template layout as you need in your project, in this tutorial we selected the Bottom Navigation Activity.
On press next button, enter the app name, package name, you can also changed project saving location other than default of android studio, then select the project language kotlin or java then press Finish button as shown in the below image
After your project starts building as showing in the below screenshot, on sync and build process do not click anywhere and internet connection should be stable otherwise sync will not be completed and in many pc or systems, again you to create a new project if failed.
Till build process is completing start creating a new project on firebase.
Goto google.com and search for firebase console or click on this link as shown in the image
After that you have to login with your gmail id which you want to use for in the project after login you will see home screen of new firebase dashboard.
After click on the Create a Project, you will see a new screen where you have to enter project name, and accept terms and confirmation and click the Continue button as like the below image
Finally click on the Create Project. After that you project is ready to use check the below below screenshot
As shown in above image click on the Android icon because we are using firebase login in our android project.
Now copy the package name from the android studio project -> build.gradle file as shown in the below image
Now enter this package name and app name in your firebase project then click on Register app as shown in the below screenshot
After that click on the Continue to console as like the below image
Then click on project name -> click on the setting icon as shown in the below image
After copy the SHA1 Key from the Android Studio as shown in the below screenshot
Now paste this SHA1 key in your firebase project as shown in the below screenshot
After save, click on the Build menu on left sidebar on top then select Authentication as shown in the below screenshot
After that click on save button. After enabled you will see enabled message in your firebase console, and if you wants to add more login option like facebook login then click on the Add new provider as shown in the below image.
After enable this you will need facebook app id and app secret to activate facebook login, so first login in to your facebook.com
after login visit to Facebook Developer then register your account here, after register click on the Create App button as shown in the below image
Select Consumer press Next button then on next page enter app name, contact email id, select your business manager account or leave it then press Create app as shown in the button
In above page enter your app package name and enter main class which opened first when you launch your app in mobile. If you have added splash screen then use splash screen in Activity name, we haven’t added any splash screens in this project so our MainActivity class is shows first when user open the app, then click on the save button and press Continue.
In next page you have to add Facebook key hash, where to get key hash or how to generate key hash?
Facebook and google provide a cmd tool to create a key hash, this way is very long and can not create acurate key hash if you made s single mistake, So how you can create it?
Don’t worry Krishna – Apps made their own tool to generate facebook key hash just in a second. Generate facebook key hash here for free. Here you have to enter the SHA1 key from the Android studio which we created in this tutorial in starting. Then press save and continue as shown in the above image.
Enable single sign on option as shown in the below image.
Then copy the code from the facebook and paste this in android studio -> app-> res-> values -> strings.xml as shown in the below image.
Then copy the facebook app id and facebook app protocol scheme values and paste it in the above screenshot values, as shown in the below image
Then paste it in strings.xml values and also copy the facebook client token follow the below screenshot to copy that
After pasting all the values it should be show like the below screenshot
Now copy the facebook app id and app secret values from facebook and paste it in the firebase console as shown in the below image
Copy the OAuth redirect uri and press save button.
Now paste this value in the facebook login -> Settings as shown in the screenshot
Press Save changes. Now you have successfully enabled google and facebook login for your app.
How to change or replace google-services.json file in android studio click here to watch a short video
If still have any problem watch the video tutorials, click on the below button to watch it.