firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

FirebaseAuthMultiFactorException not exposing MultiFactorResolver

Open RaphaelHx opened this issue 6 months ago • 0 comments
trafficstars

In Firebase, when a user has opted in for TOTP, on signIn, a FirebaseAuthMultiFactorException error is thrown in android and iOS which we expect. To continue logging in, we need the MultiFactorResolver to resolveSignIn. I see there is the MultiFactor classes defined in this library, but can't fetch the resolver out of the exception in iOS.

https://firebase.google.com/docs/auth/android/totp-mfa#sign_in_users_with_a_second_factor https://firebase.google.com/docs/auth/ios/totp-mfa#sign_in_users_with_a_second_factor

In android, as the FirebaseAuthMultiFactorException is just a typealias of the google FirebaseAuthMultiFactorException, in the androidMain I can access it like so.

actual fun extractMultiFactorResolver(e: Throwable): MultiFactorResolver? {
    val authException = e as? FirebaseAuthMultiFactorException ?: return null
    return MultiFactorResolver(authException.resolver)
}

However, in iOS, as a whole new error is thrown when this scenario happens (FirebaseAuthMultiFactorException(toString()) with just a toString() of the original error as the message in the new error, how can I acquire the resolver to continue?

RaphaelHx avatar May 13 '25 08:05 RaphaelHx