Android Question firebaseauth-authenticate error

ermales

Member
Licensed User
I guided myself in this tutorial https://www.b4x.com/android/forum/threads/firebaseauth-authenticate-your-users.67875/ works perfectly but when the device does not have access to the internet I have a problem can help me please, how to solve

this is the login code
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
'    Private ClientId As String = "706692133530-ea9e1v214b2hdrm0td9r5bt173nk7nsm.apps.googleusercontent.com"
'    Private oauth2 As GoogleOAuth2

    Public auth As FirebaseAuth
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
'    ++++++++++++++++++++++ id credencial se obtiene de registrar en el api gmail
    Private lblName As Label
   
   
    Private btnIrRegister As Button
    Private btnIniciarSesion As Button
   
    Private btnInicioGoogle As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
 
https://www.googleapis.com/auth/user.birthday.read")
    If FirstTime Then
        auth.Initialize("auth")
    End If

    Activity.LoadLayout("frmInicio")
    If auth.CurrentUser.IsInitialized Then
       
        Auth_SignedIn(auth.CurrentUser)

    End If
   
   
       
   
End Sub

Sub Activity_Resume
    
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub



Sub btnIrRegister_Click
    StartActivity(Registro)
   
End Sub

Sub btnIniciarSesion_Click
   
    StartActivity(MenuEleccion)
   
End Sub


Sub btnInicioGoogle_Click

    auth.SignInWithGoogle
   
End Sub
'+++++++++ Gmail +++++++++++++++++++++++++++++++++++++++++++

Sub Auth_SignedIn (User As FirebaseUser)
   
    Log("SignedIn: " & User.DisplayName)
'    lblName.Text = "Hello: " & User.DisplayName
    Starter.kvs.Put("Usuario",User.DisplayName)
    Starter.kvs.Put("Email",User.Email)
    Starter.kvs.Put("PhotoUrl",User.PhotoUrl)
    Starter.kvs.Put("Uid",User.Uid)
    ToastMessageShow("Hola "&User.DisplayName,False)
   
   
    StartActivity(MenuEleccion)
    Activity.Finish
   
End Sub

attached error when the device does not have access to the internet I have a problem

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzj@3e280e4
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
SignInWithGoogle.ResultArrived
ResultArrived Success
** Activity (main) Resume **
com.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host) has occurred.
    at com.google.android.gms.tasks.zzu.getResult(Unknown Source)
    at anywheresoftware.b4a.objects.FirebaseAuthWrapper$5.onComplete(FirebaseAuthWrapper.java:170)
    at com.google.android.gms.tasks.zzj.run(Unknown Source)
    at android.os.Handler.handleCallback(Handler.java:761)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:156)
    at android.app.ActivityThread.main(ActivityThread.java:6523)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
Caused by: com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host) has occurred.
    at com.google.firebase.auth.api.internal.zzds.zzb(Unknown Source)
    at com.google.firebase.auth.api.internal.zzew.zza(Unknown Source)
    at com.google.firebase.auth.api.internal.zzeo.zzc(Unknown Source)
    at com.google.firebase.auth.api.internal.zzep.onFailure(Unknown Source)
    at com.google.firebase.auth.api.internal.zzdy.dispatchTransaction(Unknown Source)
    at com.google.android.gms.internal.firebase_auth.zzb.onTransact(Unknown Source)
    at android.os.Binder.execTransact(Binder.java:565)


I also want to know how to control this error when the user is disabled in firebase, do not leave this error

B4X:
Registo conectado a: 9DLDU17302001839
--------- beginning of crash
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
SignedIn: Ricardo Males
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzj@32bf64e
** Activity (main) Pause, UserClosed = true **
sending message to waiting queue (auth_signedin)
** Activity (menueleccion) Create, isFirst = true **
** Activity (menueleccion) Resume **
** Activity (menueleccion) Pause, UserClosed = true **
** Activity (menucomida) Create, isFirst = true **
** Activity (menucomida) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzj@32bf64e
** Activity (menucomida) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
running waiting messages (1)
SignedIn: Ricardo Males
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (menueleccion) Create, isFirst = false **
** Activity (menueleccion) Resume **
** Activity (menueleccion) Pause, UserClosed = true **
** Activity (menucomida) Create, isFirst = false **
** Activity (menucomida) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzj@32bf64e
** Activity (menucomida) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
SignInWithGoogle.ResultArrived
ResultArrived Success
** Activity (main) Resume **
com.google.android.gms.tasks.RuntimeExecutionException: com.google.firebase.auth.FirebaseAuthInvalidUserException: The user account has been disabled by an administrator.
    at com.google.android.gms.tasks.zzu.getResult(Unknown Source)
    at anywheresoftware.b4a.objects.FirebaseAuthWrapper$5.onComplete(FirebaseAuthWrapper.java:170)
    at com.google.android.gms.tasks.zzj.run(Unknown Source)
    at android.os.Handler.handleCallback(Handler.java:761)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:156)
    at android.app.ActivityThread.main(ActivityThread.java:6523)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
Caused by: com.google.firebase.auth.FirebaseAuthInvalidUserException: The user account has been disabled by an administrator.
    at com.google.firebase.auth.api.internal.zzds.zzb(Unknown Source)
    at com.google.firebase.auth.api.internal.zzew.zza(Unknown Source)
    at com.google.firebase.auth.api.internal.zzeo.zzc(Unknown Source)
    at com.google.firebase.auth.api.internal.zzep.onFailure(Unknown Source)
    at com.google.firebase.auth.api.internal.zzdy.dispatchTransaction(Unknown Source)
    at com.google.android.gms.internal.firebase_auth.zzb.onTransact(Unknown Source)
    at android.os.Binder.execTransact(Binder.java:565)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I think the relevant info from the error is

"The User account has been disabled by an administrator."
 
Upvote 0

ermales

Member
Licensed User
I think the relevant info from the error is

"The User account has been disabled by an administrator."

Thank you for answering.

some way to control the error when the user is disabled by the administrator, the application closes unexpectedly
 
Upvote 0

ermales

Member
Licensed User
Please post the logs as text instead of screenshot.

Where is the relevant code? Does the app crash?

I updated my post,
I have two problems as you explained in the post:
1.- The app closes when I don't have access to the internet and I want to log in.
2.- When I try to log in and the user is disabled by the administrator in firebase the app closes unexpectedly. I want to indicate a message in my app that the user is disabled.
 
Upvote 0

ermales

Member
Licensed User
how to solve the problem I have that is to tell the user that his account is disabled, some way ?
I updated my post,
I have two problems as you explained in the post:
1.- The app closes when I don't have access to the internet and I want to log in.
2.- When I try to log in and the user is disabled by the administrator in firebase the app closes unexpectedly. I want to indicate a message in my app that the user is disabled.

error: com.google.firebase.auth.FirebaseAuthInvalidUserException: The user account has been disabled by an administrator.

how to solve the problem I have that is to tell the user that his account is disabled, some way ?
 
Upvote 0

ermales

Member
Licensed User
hoinestly i dont know. Go to the console, select authentification and watch the userlist. ACTIVATE the user whichs account is disabled. This is what i would try...

tv_073.png

obviously you would have to do that, but the administrator wants to disable the user and the user has to know that his account is disabled.

I want to print this message
error: com.google.firebase.auth.FirebaseAuthInvalidUserException: The user account has been disabled by an administrator.
in my application
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can probably use the http Rest api to get this info for a user.

It is also available in the firebase Admin Library. There is a property isDisabled for a Useraccount.

B4X:
    Dim user As UserRecord = fba.getUserAsync("oqxH0hCVr5e5SPuOHo7MxshPaqA2")
    Log(user.isDisabled)
 
Upvote 0

ermales

Member
Licensed User
LOG
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
SignInWithGoogle.ResultArrived
ResultArrived Success
** Activity (main) Resume **
firebaseAuthWithGoogle success: false
error: com.google.firebase.auth.FirebaseAuthInvalidUserException: The user account has been disabled by an administrator.

any way to capture this message
SignInWithGoogle.ResultArrived
ResultArrived Success
 
Upvote 0
Top