33 thoughts on “Firebase Classic Email Login and Facebook Login Tutorial on Android

  • July 17, 2016 at 8:58 am
    Permalink

    Thank u sir.for this tuto.i used it.and it work.but i just noticed something.what i noticed is for signup when the field are empty and we press the sign up button,t the progress bar is shown instead to notify that the field are blank.
    Thank u sir

    Reply
    • July 17, 2016 at 7:41 pm
      Permalink

      Yeah thank you for your thought. That’s true and we can include a method which will validate the form before submitting it. Hope you enjoyed our Article 🙂

      Reply
  • July 18, 2016 at 3:02 pm
    Permalink

    Thank you Sir. Please make a tutorial on Google Sign in using Firebase.

    Reply
  • July 28, 2016 at 10:11 am
    Permalink

    Wow, Very very useful tutorial. and very clear for every level of person like expert or new.

    Thank you very much for posting. i a really appreciate you effort.

    Reply
    • July 28, 2016 at 5:09 pm
      Permalink

      Thank You:) Glad it could help 🙂

      Reply
  • August 2, 2016 at 12:56 pm
    Permalink

    im getting this error:-
    The parameter app_id is required.

    help me out sir !

    Reply
    • August 2, 2016 at 4:21 pm
      Permalink

      Hello Anshul, In the strings.xml file you need to replace “app_id” with YourApp Id which you obatin from facebook developers site. The process of getting facebook App Id is explained in the Part 3 of this tutorial. So if you replace app_id resource with the facebook App Id which you obtain from facebook developers page , then you are good to go:)

      Reply
      • August 3, 2016 at 5:56 am
        Permalink

        Sir,
        its already pasted with facebook app id
        50 *some digits* 00
        50 *some digits* 00

        and one more thing ,I’m getting the value of myFirebaseRef.getAuth() value as null.

        Reply
        • August 3, 2016 at 3:30 pm
          Permalink

          Make sure you have followed these steps :
          1 . Creating a firebase application in Firebase console and pasting your google-services.json file in the project’s app folder.
          2. Make sure you have Enabled Facebook Login and Email Login in the Auth tab of your Firebase console.
          3. Make sure you have created an application in Facebook developers page and get your App Id. You need to paste this App Id in Strings.xml. Also while enabling Facebook Login you need to paste the App Id and App secret in the Auth Tab of firebase console.
          4. Make sure you have added all the dependencies in App level and Project level build.gradle files.
          5. Make sure you have changed Database Rules in the Firebase console.

          Reply
  • August 4, 2016 at 1:50 am
    Permalink

    Hello, After the enter my email and pass, the app says permission denied in a toast and shows the 2 buttons .
    I can say that happening.
    Thank you.

    Reply
    • August 4, 2016 at 5:00 pm
      Permalink

      Hi Kevin,Have you signed up before trying to log in? And Have you enabled Email and Password login in your Firebase console?

      Also Make sure you have followed these steps :
      1 . Creating a firebase application in Firebase console and pasting your google-services.json file in the project’s app folder.
      2. Make sure you have Enabled Facebook Login and Email Login in the Auth tab of your Firebase console.
      3. Make sure you have created an application in Facebook developers page and get your App Id. You need to paste this App Id in Strings.xml. Also while enabling Facebook Login you need to paste the App Id and App secret in the Auth Tab of firebase console.
      4. Make sure you have added all the dependencies in App level and Project level build.gradle files.
      5. Make sure you have changed Database Rules in the Firebase console.

      Reply
  • August 5, 2016 at 9:45 pm
    Permalink

    Hi, I j iust wanted to say thank you so much for this tutorial… you have no idea how much I tried to understand Firebase and Facebook.

    I’m having a problem though, it may be my configuration of the Firebase database. The app logs in and is stuck in the LoadingDialog. The app says you are logged in, Facebook says I am logged in, but Firebase is not registering anything on their end. But it doesn’t go to MainActivity. Log out works great. The logs give me a consistent “E/eglCodecCommon: **** ERROR unknown type” error.

    I am using the sample app you let us download, and put my unique Facebook ID and Firebase URL in there. I’ve created another app in the Firebase Console and put the .json file there. Gradle files are the same.

    Again, thank you so much.

    Reply
    • August 7, 2016 at 1:08 pm
      Permalink

      HI Pemaz. I am glad to hear from you:) Did you replace the google-services.json file in the app folder of the downloaded project with your google-services.json file? And do you have problem logging-in using both facebook and Email methods? or just facebook login?

      Can you please try this tutorial. You follow each and every step from the beginning and let me know whether that application works fine or not. It includes just Google Sign-in.

      Reply
      • August 9, 2016 at 6:37 pm
        Permalink

        SORRY, i didn’t see your reply. Yeah, the other project worked out for me.
        I actually figured out the problem, through hours of Google. It’s weird, even though I did take the sample project and just add all my unique identifers (Facebook ID / Firebase URL / .json file), it wouldn’t work for me. Eventually, after lots of Googling, I changed the database rules and added some files to the Gradle. Hopefully, it helps someone else.
        Gradle (app):
        dependencies {
        compile ‘com.android.support:appcompat-v7:23.1.1’
        compile ‘com.android.support:design:23.1.1’
        compile ‘com.firebase:firebase-client-android:2.5.2+’
        compile ‘com.google.android.gms:play-services-auth:9.2.0’
        compile ‘com.firebaseui:firebase-ui:0.4.4’
        }
        apply plugin: ‘com.google.gms.google-services’

        Database rules
        {
        “rules”: {
        “users”: {
        “$uid”: {
        “.read”: “auth == null”, //even non-authorised users CAN read
        “.write”: “auth == null” //even non-authorised users CAN write
        }
        }
        }
        }

        Reply
        • August 10, 2016 at 3:30 pm
          Permalink

          Hello Pemaz, Thank you for your time. Very glad to hear from you. In the 11th step of Part ! of this tutorial i have put an image which shows how security rules should look. Please try with it. Though your solution works, i feel we cant give access to read and write every node of your firebase database. Please do try with it and let me know the result:)

          This is how Rules should look for this project : {
          “rules”: {
          “users”: {
          “$uid”: {
          “.read”: true,
          “.write”: true
          }
          }
          }
          }

          Reply
    • August 7, 2016 at 1:20 pm
      Permalink

      Also please paste the whole logcat content you get when you run the app in your emulator on pastebin.com and give me the URL. I will look in to it. Thank you:)

      Reply
  • August 9, 2016 at 7:21 pm
    Permalink

    Hi thank you for this great tutorial, I have two issues with the app. As one person mentionned earlier I receive a toast saying “permission denied” even though the user is properly recorded when using the email and password method.

    However the facebook method doesn’t work at all, I receive a toast “authentification failed”, and it doesn’t go any further.

    http://pastebin.com/brtisNW2

    here’s a pastebin of the logcat.

    Cheers,

    Aurélien.

    Reply
    • August 10, 2016 at 3:53 pm
      Permalink

      Hello Aurélien, Glad to hear from you.

      Regarding ‘persmission denied’ error, have you changed your Database rules as mentioned in the 11th step of Part ! of this tutorial?

      And regarding ‘authentication failed’ have you enabled facebook login in the firebase Auth Tab by pasting Your facebook App Id and App secret?
      Also you need to paste this OAuth redirect URI in the Products section of your Facebook developers dashboard.

      Reply
      • August 14, 2016 at 3:10 pm
        Permalink

        Hello thanks for the very quick return,

        Well, I indeed did all the aforementioned steps, from the DB rules to the App ID and secret. I pasted the URI in the Facebook login product section.

        I’m pursuing my “investigation” as to what’s wrong with my setup.

        Cheers,

        Aurélien.

        Reply
  • August 18, 2016 at 9:18 pm
    Permalink

    Hello. The tutorial is very helpful to me, thank you.
    I have a question, when logging in with Facebook, how to track user’s session? When i run, it throws an error with one line “Error occured when logging in. Try again later”.
    Look forward for your respond. Thanks.

    Reply
    • August 19, 2016 at 5:28 pm
      Permalink

      Hello Giang, Glad to hear from you. So you are able to login using Email and password method but not with Facebook method? Make sure you have enabled Facebook Login method. Also have you pasted the valid OAuth redirect URIs in the Products section of your Facebook developers dashboard? You get OAuth redirect URI from firebase console while enabling Facebook Login method. Also please verify the APP ID and APP Secret in Firebase console with that of your Facebook project.

      Reply
      • August 28, 2016 at 4:08 pm
        Permalink

        I’ve already done those steps that you mentioned. My problem is that when I run on emulator (does not have Facebook app), it’s ok, but when I run on my real phone, it prompted that error. I wonder if the Facebook application caused the problem.
        I also thank you for your reply.

        Reply
  • September 20, 2016 at 9:22 pm
    Permalink

    Hello, I’m a beginner when it comes to Firebase. I’m getting an error that I can’t figure out. In the SignUp activity I am getting an “Authentication failed” from my task when trying to create a user using the Email/Password method.

    I’ve double checked my Rules, google-services.json is there, classpath for google-services, latest Google Repository/Google Play, and gradle dependencies/applying the plugin for google-services.

    Any parts that I might have missed other than that? Also thank you for the tutorial!

    Reply
    • September 21, 2016 at 2:31 pm
      Permalink

      Hello Jeremy, Glad to hear from you. Have you enabled Email And Password Login in the Auth tab of your Firebase console?

      Reply
  • September 21, 2016 at 7:58 pm
    Permalink

    i am getting Authentication failed as before some days it was working but now it showing toast Authentication failed and i have checked every rules ,facebook developers option, code as well.. please help what should i do..!

    Reply
  • October 17, 2016 at 5:26 pm
    Permalink

    I’m getting permission denied although it logs in , it just doesn’t display welcome text

    Reply
    • October 17, 2016 at 6:00 pm
      Permalink

      Hello Jerry, Can you please post your logcat message? You can paste your logcat message on http://pastebin.com and give me a pastebin link to your file. Make sure you have enabled Login permissions in the Auth tab of your firebase console.

      Reply
  • November 20, 2016 at 1:33 pm
    Permalink

    Can you add password reset maybe and activation email?

    Reply
    • November 21, 2016 at 2:54 am
      Permalink

      Thanks for your comment Jarno. I will try to add it soon 🙂

      Reply
  • December 2, 2016 at 12:20 pm
    Permalink

    hello sir
    when I login first time then it is login show name and profile pic but when I am logging its again then it come on login screen after finish progress bar.
    Please help me find out this problem
    thank you

    Reply
  • December 26, 2016 at 1:04 pm
    Permalink

    Hey thank you for posting:)

    I am facing problem for getting email id from facebook can you please .
    auth. task.getResult().getUser().getEmail() is received null when execute bellow code:

    AuthCredential credential = FacebookAuthProvider.getCredential(accessToken.getToken());

    mAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener() {
    @Override
    public void onComplete(@NonNull Task task) {

    Log.d(TAG, “signInWithCredential”);
    String email = task.getResult().getUser().getEmail();
    }

    }
    });

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *