Skip to content

IllegalArgumentException thrown by startActivityForLinkWithProvider when SMS multi-factor authentication enabled #6412

Open
@SteveByrneOutput

Description

@SteveByrneOutput

Environment

  • Android Studio version: Ladybug | 2024.2.1
  • Firebase Component: Auth
  • Component version: firebaseBom = "33.1.2"

Issue

startActivityForLinkWithProvider throws an IllegalArgumentException if the firebaseUser has SMS multi-factor authentication enabled and configured.

If the firebaseUser does not have SMS multi-factor authentication enabled and configured the call will run as expected and trigger either addOnSuccessListener or addOnFailureListener depending on the outcome.

When SMS multi-factor authentication is enabled the callbacks are not triggered.
The user can log in on chrome as expected with their Microsoft credentials and when the app is brought to the foreground again the exception is thrown.
There are no other calls to Firebase auth at this time.

Prior to calling startActivityForLinkWithProvider(...) the user is successfully reauthenticated.

FirebaseAuth.getInstance().currentUser!!.reauthenticate(...) throws FirebaseAuthMultiFactorException as expected

multiFactorResolver.resolveSignIn(...) returns a success as expected.

Wrapping the block in a try/catch does not catch the exception.

Steps to reproduce:

  1. Enable and configure SMS multi-factor authentication in Firebase
  2. Enable and configure Microsoft authentication in Firebase
  3. Enable MFA on Firebase user account
  4. Attempt to link Microsoft account to Firebase User account

Relevant Code:

val activity = (LocalContext.current as ComponentActivity)

val provider = OAuthProvider.newBuilder("microsoft.com")
	.addCustomParameter("prompt", "consent").build()

FirebaseAuth.getInstance().currentUser!!.startActivityForLinkWithProvider(
    	activity,
    	provider
	).addOnSuccessListener {
		Timber.i("Success")
	}.addOnFailureListener {
		Timber.e(it)
	}

Stacktrace:

FATAL EXCEPTION: Firebase Blocking Thread #5
            java.lang.IllegalArgumentException: Given String is empty or null
                 	at com.google.android.gms.common.internal.Preconditions.checkNotEmpty(com.google.android.gms:play-services-basement@@18.3.0:2)
                 	at com.google.android.gms.internal.firebase-auth-api.zzagc.<init>(com.google.firebase:firebase-auth@@23.1.0:5)
                 	at com.google.android.gms.internal.firebase-auth-api.zzzk.zza(com.google.firebase:firebase-auth@@23.1.0:114)
                 	at com.google.android.gms.internal.firebase-auth-api.zzzk.zza(com.google.firebase:firebase-auth@@23.1.0:20)
                 	at com.google.android.gms.internal.firebase-auth-api.zzaah.zza(com.google.firebase:firebase-auth@@23.1.0:5)
                 	at com.google.android.gms.internal.firebase-auth-api.zzaeo.zza(com.google.firebase:firebase-auth@@23.1.0:20)
                 	at com.google.android.gms.internal.firebase-auth-api.zzaeo.zza(com.google.firebase:firebase-auth@@23.1.0:64)
                 	at com.google.android.gms.internal.firebase-auth-api.zzadv.zza(com.google.firebase:firebase-auth@@23.1.0:168)
                 	at com.google.android.gms.internal.firebase-auth-api.zzaae.zza(com.google.firebase:firebase-auth@@23.1.0:9)
                 	at com.google.android.gms.internal.firebase-auth-api.zzzk.zza(com.google.firebase:firebase-auth@@23.1.0:88)
                 	at com.google.android.gms.internal.firebase-auth-api.zzzk.zza(com.google.firebase:firebase-auth@@23.1.0:143)
                 	at com.google.android.gms.internal.firebase-auth-api.zzadh.zza(com.google.firebase:firebase-auth@@23.1.0:106)
                 	at com.google.android.gms.internal.firebase-auth-api.zzabu.zza(com.google.firebase:firebase-auth@@23.1.0:15)
                 	at com.google.android.gms.internal.firebase-auth-api.zzaeh.run(com.google.firebase:firebase-auth@@23.1.0:2)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                 	at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47)
                 	at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                 	at java.lang.Thread.run(Thread.java:1012)

Dependencies

firebaseBom = "33.1.2"

firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" }
firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics" }
firebase-config = { group = "com.google.firebase", name = "firebase-config" }
firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics" }
firebase-firestore = { group = "com.google.firebase", name = "firebase-firestore" }
firebase-storage = { group = "com.google.firebase", name = "firebase-storage" }
firebase-appcheck-playintegrity = { group = "com.google.firebase", name = "firebase-appcheck-playintegrity" }
firebase-auth = { group = "com.google.firebase", name = "firebase-auth" }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions