mirzemehdi / KMPAuth

Kotlin Multiplatform Authentication Library targetting android and iOS
https://mirzemehdi.com/KMPAuth/
Apache License 2.0
178 stars 16 forks source link

Firebase throws a serialization exception if a user tries to sign in from restricted region. #11

Closed BehnamMaboodi closed 5 months ago

BehnamMaboodi commented 6 months ago

When a user attempts to use Google sign-in from a restricted region and fills out the Google sign-in form, Firebase crashes with the following error:

com.google.firebase.FirebaseException: An internal error has occurred. [ Json conversion failed! Failed to parse error for string [<!DOCTYPE html><html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 403 (Forbidden)!!1</title> ... As a result, the app crashes. However, if a user tries Apple sign-in, Firebase throws an error without causing a crash. But we still wouldn't know if the user canceled the sign-in flow or if something else happened.

I attempted to handle the exception by using a try-catch block when invoking the Google sign-in onClick function, but it didn't resolve the problem:

  GoogleButtonUiContainerFirebase(onResult = onFirebaseResult) {
            GoogleSignInButton(modifier = Modifier.fillMaxWidth()) { 
                  try{   this.onClick()    }
                  catch(_:Exception) {}
                 }
        } 

This crash isn't related to KMPAuth, but since Firebase is being utilized under the hood, I can't catch the exception in my code due to lack of direct access to Firebase. I believe this issue could be resolved if we incorporate a try-catch block inside the library code.

mirzemehdi commented 6 months ago

@BehnamMaboodi This will be fixed in next relase