Many apps require log-in functionality, perhaps to provide users with dedicated data storage. Firebase makes it easy as it can get. You can even use one of Google’s ready-made authentication screens.

And that’s exactly what we’re gonna do.

Enable Providers in the Console

Go the Firebase Console then navigate to Authentication > Sign-in Method, then enable all your desired log-in methods. Email/password is a standard one and in my opinion, should always be enabled for most apps.

Import the Dependencies

Add these to your app-level  build.gradle file.

*Note: If you want to include Google, Facebook, or Twitter log in, you can find out how to enable that on the official docs.

1. Create a List of your Providers

Just remember AuthUI.IdpConfig. Most of the code here stems from that.

2. Use AuthUI to Create a SignInIntent

This will launch the ready-made authentication screen provided by FirebaseUI. The screen will adjust itself based on the providers you passed into it to suit these needs.

3. Respond in OnActivityResult

Let your app know your user has signed in after the sign-in flow so you can take the necessary actions.

Theming the Sign-In Flow

By default, FirebaseUI uses your app’s theme. You can however, pass in a seperate theme for it to use, or perhaps a logo.

Or you can set a custom privacy policy and terms of service.

Signing Out with FirebaseUI

To my surprise, FirebaseUI even provides its own sign out method. What’s different you may ask? You can add an onCompleteListener to it! That’s it. No fancy UI gimmicks here.

And that is all… from me at least

I don’t think I added much necessary optimisation to this topic. The official docs actually have FirebaseUI structured quite nicely, and it’s easily understandable.