You can integrate Firebase Authentication with a custom authentication system by modifying your authentication server to produce custom signed tokens when a user successfully signs in. Your app receives this token and uses it to authenticate with Firebase.
Before you begin
- If you haven't already, add Firebase to your Android project .
- In your module (app-level) Gradle file
(usually
<project>/<app-module>/build.gradle.ktsor<project>/<app-module>/build.gradle), add the dependency for the Firebase Authentication library for Android. We recommend using the Firebase Android BoM to control library versioning.dependencies { // Import the BoM for the Firebase platform implementation ( platform ( "com.google.firebase:firebase-bom:34.6.0" )) // Add the dependency for the Firebase Authentication library // When using the BoM , you don't specify versions in Firebase library dependencies implementation ( "com.google.firebase:firebase-auth" ) }
By using the Firebase Android BoM , your app will always use compatible versions of Firebase Android libraries.
(Alternative) Add Firebase library dependencies without using the BoM
If you choose not to use the Firebase BoM , you must specify each Firebase library version in its dependency line.
Note that if you use multiple Firebase libraries in your app, we strongly recommend using the BoM to manage library versions, which ensures that all versions are compatible.
dependencies { // Add the dependency for the Firebase Authentication library // When NOT using the BoM , you must specify versions in Firebase library dependencies implementation ( "com.google.firebase:firebase-auth:24.0.1" ) }
- Get your project's server keys:
- Go to the Service Accounts page in your project's settings.
- Click Generate New Private Key at the bottom of the Firebase Admin SDK section of the Service Accounts page.
- The new service account's public/private key pair is automatically saved on your computer. Copy this file to your authentication server.
Authenticate with Firebase
- In your sign-in activity's
onCreatemethod, get the shared instance of theFirebaseAuthobject:Kotlin
private lateinit var auth : FirebaseAuth // ... // Initialize Firebase Auth auth = Firebase . auth . kt

