Add Google-login to a Flutter app using Firebase Authentication [ 5 minute tutorial]

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 มิ.ย. 2022
  • Learn how to add Google-login to a Flutter app in less than 5 minutes. A fast tutorial with to-the-point instructions.
    Important links:
    A longer version of the video will be available here - [Will be available by tomorrow].
    Learn more about getting the SHA-1 key: developers.google.com/android...
    Copy-Paste items:
    1. Command to get debug SHA-1 (for Windows): keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
    2.Add firebase_auth package: flutter pub add firebase_auth
    3.Add google_sign_in package: flutter pub add google_sign_in
    Prerequisites:
    Add Firebase to Flutter: • How to Add Firebase to...
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 78

  • @hamzasiddiqui1196
    @hamzasiddiqui1196 ปีที่แล้ว +2

    4:30 I was missing this step.. thanks for highlighting it.

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Hi Hamza, thanks for commenting. Stay connected.

  • @shuamilabs
    @shuamilabs 5 หลายเดือนก่อน

    thank you for this tutorial. it help me.

    • @droidmonk4820
      @droidmonk4820  5 หลายเดือนก่อน

      Glad it helped.
      Stay Connected.

  • @sahadevkunwar9426
    @sahadevkunwar9426 ปีที่แล้ว

    Really helped thanks buddy

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Glad it helped, STAY CONNECTED

  • @sulemanali8542
    @sulemanali8542 ปีที่แล้ว

    It really helped sir kindly request to you to make more tutorials on firebase plz

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Thanks for commenting Suleman. New videos are coming soon. Stay connected.

  • @nanjiboyy7007
    @nanjiboyy7007 ปีที่แล้ว +1

    Amazing video thanks

  • @DilipKumar-ou2pn
    @DilipKumar-ou2pn ปีที่แล้ว

    really appreciate it thanks a lot

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Glad it helped, stay connected.

  • @liewpeimun5369
    @liewpeimun5369 ปีที่แล้ว

    hi bro, how to remove Black Status Bar Slide to Bottom after tapping the GoogleLoginButton?

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Hi, I have found that this issue has been reported. You can find some solutions the thread below. I haven't tried the solutions yet, if you try then let us all know if it worked for you .
      github.com/flutter/flutter/issues/48371

  • @SayedTahsin
    @SayedTahsin ปีที่แล้ว

    Whenever I am selecting my mail its not working. (showing the following error on console and getting back at the same page) error: Expecting binder but got null!
    Can you plz provide me a solution here?

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Hi , are you still having the issue. Are you using an emulator?

  • @roomian
    @roomian ปีที่แล้ว +1

    How would you implement the stay logged in feature in this code? Suppose the user opened the app for the first time and they logged in using the "sign in with google plus" icon and then after selecting desired google account the user goes to the home page. The user then closes the application(doesn't log out) and upon reopening the app again the user should not face the signin or login page again. The user should go straight to the home page of the application and this should keep happening until the user presses a logout button. I implemented this code but the code started acting weird. The sign in pop up kept appearing, the stay logged in feature stopped working only after I had implemented the google auth. I haven't used your code yet as I didn't know how to implement the stay logged in feature in your code. Could you help me with this?

    • @roomian
      @roomian ปีที่แล้ว +1

      So I implemented your code into my app and you have already implemented the stay logged in feature( I don't understand how, I'm new to flutter, I was using instance.user before to detect if there was a current user with logged in credentials). The problem of the app acting weird is still there. The choose an account pop up appears repeatedly only after I logout of the app after signing in while the app is running. If I sign in the app for the first time. Close the app. Restart the app and then log out then the issue doesn't appear.

    • @roomian
      @roomian ปีที่แล้ว

      please help :_)

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว +1

      Hi Taimoor , thanks for reaching out. I would love to help you, but from your explanation the problem is not yet clear to me. I would better if you somehow can share the related code.

    • @roomian
      @roomian ปีที่แล้ว +1

      @@droidmonk4820 Thank you so much for the response sir. The issue was solved. Apparently you have to dispose of any timer functions if you want to use any of the social services like google login, facebook login etc. That was the issue. I used your code too it works really well. Thank you so much.

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว +1

      Thanks for sharing your solution Taimoor, it will help others. Stay connected.

  • @unknown38835
    @unknown38835 หลายเดือนก่อน

    Gran video, me sirvió muchísimo

    • @droidmonk4820
      @droidmonk4820  หลายเดือนก่อน

      me alegro de escuchar eso
      Mantente conectado

  • @JBtronic
    @JBtronic ปีที่แล้ว

    I was facing error on cmd regarding keytool. I set it by setting environment variable. After that, I was facing issue while typing keystore password. I tried 'changeit' or simple enter press but nothing works but then i found solution that was to simply write 'android' when it ask for keystore password.

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว +1

      Yah, the default keystore password for debug certificate is "android"

    • @mehakjiwani864
      @mehakjiwani864 7 หลายเดือนก่อน

      can you please elaborate how did u set enviroment variable

  • @lufthazka
    @lufthazka ปีที่แล้ว

    everything went well, but why when I log out and then log in again a second time using the same account, the page doesn't move to home instead it stays on the login page. There is no error even displayName has appeared in the console.

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Are you checking the authentication status before loading the pages?

    • @lufthazka
      @lufthazka ปีที่แล้ว

      @@droidmonk4820 forget it, turns out I forgot to remove the navigator.pushReplacement after the signout code 😂, and now it's working fine. Thank you sir

  • @nguyentantien6262
    @nguyentantien6262 10 หลายเดือนก่อน

    thank you so much

    • @droidmonk4820
      @droidmonk4820  10 หลายเดือนก่อน

      Glad you liked it, stay connected.

  • @moshehta2827
    @moshehta2827 7 หลายเดือนก่อน

    Awsome ❤❤

    • @droidmonk4820
      @droidmonk4820  7 หลายเดือนก่อน

      Thanks 😊
      Stay connected.

  • @flutter_oomg-xi5nq
    @flutter_oomg-xi5nq 10 หลายเดือนก่อน

    Nice video brother make more

    • @droidmonk4820
      @droidmonk4820  10 หลายเดือนก่อน

      Trying to make more bro. Stay connected.
      Thanks for commenting.

  • @battlegroundsinindia1336
    @battlegroundsinindia1336 ปีที่แล้ว

    well done bro

  • @nomanabdulmalik7904
    @nomanabdulmalik7904 2 ปีที่แล้ว +1

    I'm facing this error how I can solve it, kindly reply:
    throw PlatformException(code: errorCode, message: errorMessage as String?, details: errorDetails, stacktrace: errorStacktrace);

    • @droidmonk4820
      @droidmonk4820  2 ปีที่แล้ว +1

      Can you share some more information about the error?

    • @nomanabdulmalik7904
      @nomanabdulmalik7904 2 ปีที่แล้ว

      @@droidmonk4820
      Here is my code when I call this function on button and pressed button it shows error which was mention in 1st comment.
      signInWithGoogle() async {
      GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
      GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;
      AuthCredential credential = GoogleAuthProvider.credential(
      accessToken: googleAuth?.accessToken,
      idToken: googleAuth?.idToken,
      );
      UserCredential userCredential =
      await FirebaseAuth.instance.signInWithCredential(credential);
      if (userCredential.user != null) {
      Navigator.of(context)
      .pushReplacement(MaterialPageRoute(builder: (context) => TodoAPP()));
      }
      }

    • @earthplanet1541
      @earthplanet1541 ปีที่แล้ว

      @@droidmonk4820 When I try to do the code on web I get the same Issue, can you make a video on how to do auth on web and mobile in the same app?

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว +1

      I shall create a video for sure, but for now just try to make sure that you are adding the appropriate SHA key. The issue seems to be related to the SHA-1 key.
      You can find more information on : developers.google.com/android/guides/client-auth
      You can also get the the SHA-1 key using gradle's singing report:
      developers.google.com/android/guides/client-auth#using_gradles_signing_report

  • @jonyifamily7311
    @jonyifamily7311 6 หลายเดือนก่อน

    Sorry mster but no thing display when I click on the button of login

    • @droidmonk4820
      @droidmonk4820  6 หลายเดือนก่อน +1

      Take a look at the console and see if you get any information about an error, if you find then share with me.
      And thanks for reaching out, stay connected.

    • @jonyifamily7311
      @jonyifamily7311 6 หลายเดือนก่อน

      @@droidmonk4820 the error is google sign in canceled I tried a lot but with out any benefits

  • @shadyardotdev
    @shadyardotdev 3 หลายเดือนก่อน

    Is it same for mac? does not anything else?

    • @droidmonk4820
      @droidmonk4820  3 หลายเดือนก่อน

      It is the same. Thanks for commenting.
      And sorry for the delay in responding.

    • @shadyardotdev
      @shadyardotdev 3 หลายเดือนก่อน +1

      @@droidmonk4820 NP bro, thank you very much

  • @user-ss1sz1ks7e
    @user-ss1sz1ks7e 3 หลายเดือนก่อน

    Thank uyo

    • @droidmonk4820
      @droidmonk4820  3 หลายเดือนก่อน

      Welcome, Stay connected.

  • @thc8706
    @thc8706 3 หลายเดือนก่อน

    thank you. I do successfully. But you forgot to replace the google-services.json file

    • @droidmonk4820
      @droidmonk4820  3 หลายเดือนก่อน

      Thanks, I shall check.
      Stay connected.

  • @robertciobanu622
    @robertciobanu622 ปีที่แล้ว

    hi, could you help me?

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      What kind of help do you need?

  • @maicolr8083
    @maicolr8083 9 หลายเดือนก่อน

    I LOVE YOU SO MUCH (you salve my @ss), you don't know how much appreciate that

    • @droidmonk4820
      @droidmonk4820  9 หลายเดือนก่อน +1

      Keep working your @ss off buddy. Stay connected.

  • @psjcreations2749
    @psjcreations2749 ปีที่แล้ว

    Getting error by the key code

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Hi, thanks for reaching out. Would you share some more information about the error .

  • @kevalpagada3031
    @kevalpagada3031 ปีที่แล้ว

    bro i get error

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Can you share the exact error that you are getting?

  • @hemangaborah8526
    @hemangaborah8526 2 หลายเดือนก่อน

    Arey bapu! Okhomiya neki?

    • @droidmonk4820
      @droidmonk4820  2 หลายเดือนก่อน

      হয় বন্ধু, ভাল লাগিল লগ পাই 🤗, Stay connected.

  • @oumaimasouid5229
    @oumaimasouid5229 ปีที่แล้ว

    Exception has occurred. PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null, null)) how solve it plz

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Hi thanks for reaching out.
      Have you added a support email in your firebase project settings?

  • @GumBoomm
    @GumBoomm ปีที่แล้ว

    keytool error: java.lang.Exception: Keystore file does not exist: %USERPROFILE%.android\debug.keystore
    java.lang.Exception: Keystore file does not exist: %USERPROFILE%.android\debug.keystore
    at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:923)
    at java.base/sun.security.tools.keytool.Main.run(Main.java:423)
    at java.base/sun.security.tools.keytool.Main.main(Main.java:416)

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      Which operating system are you using?
      And thanks for reaching out GUM.

    • @abemelekermias7592
      @abemelekermias7592 7 หลายเดือนก่อน

      i am facing the same problem and i am using windows
      @@droidmonk4820

  • @soufianch8481
    @soufianch8481 ปีที่แล้ว

    i try your methode but result ?? plz help me
    C:\>keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%.android\debug.keystore
    'keytool' n’est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      "'keytool' is not recognized as an internal command
      or external, an executable program or a batch file."
      --you are getting this as keytool is not added to the environment variable of your system.
      You have to add the path of the directory containing the keytool executable to your %PATH% environment variable.

    • @soufianch8481
      @soufianch8481 ปีที่แล้ว

      @@droidmonk4820 thanks for replay but i don't exist any solutions

    • @droidmonk4820
      @droidmonk4820  ปีที่แล้ว

      @@soufianch8481 check the solution in the link below
      stackoverflow.com/a/6211931

  • @abhishekbhujel4158
    @abhishekbhujel4158 2 หลายเดือนก่อน

    Hi Iam gettting this error Google sign-in failed: com.google.android.gms.common.api.ApiException: 10:

    • @droidmonk4820
      @droidmonk4820  2 หลายเดือนก่อน

      This happens when you add a wrong SHA1 key, you have to get the SHA1 for your system.

    • @abhishekbhujel4158
      @abhishekbhujel4158 2 หลายเดือนก่อน

      ​@@droidmonk4820 i generated new sha1 and added but still getting same error

    • @droidmonk4820
      @droidmonk4820  2 หลายเดือนก่อน

      @@abhishekbhujel4158 verify whether you have create the SHA1 for the correct build debug/release

    • @abhishekbhujel4158
      @abhishekbhujel4158 2 หลายเดือนก่อน

      @@droidmonk4820 hi I solved the problem and used your code for a successful google sign in.

    • @aghashabih2299
      @aghashabih2299 หลายเดือนก่อน

      @@droidmonk4820 I have done the same SHA 1 and 256 both added using keytool -list -v \
      -alias androiddebugkey -keystore ~/.android/debug.keystore from mac but still same issue on ANDROID