B4A Library FirebaseAuth - Authenticate your users

Status
Not open for further replies.
This library requires B4A v6+.

It allows the users to sign in to your app with their Google account (more identity providers will be added in the future).

upload_2016-6-13_16-31-40.png


Like all Firebase services it is quite simple to integrate this service in your app.

1. Follow this tutorial and make sure to add the Firebase Auth manifest snippet: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

2. This service requires that the signing key SHA1 signature is set in the Firebase project settings:

SS-2016-06-13_16.36.56.png


You can find this value under Tools - Private Sign Key, in the signature field:

SS-2016-06-13_16.38.08.png


Initialize the FirebaseAuth object and call SignInWithGoogle to sign in. Note that the user will be signed in automatically when the program restarts.
B4X:
Sub Process_Globals
   Private auth As FirebaseAuth
End Sub

Sub Globals
   Private lblName As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     auth.Initialize("auth")
   End If
   Activity.LoadLayout("1")
   If auth.CurrentUser.IsInitialized Then Auth_SignedIn(auth.CurrentUser)
End Sub

Sub btnSignIn_Click
   auth.SignInWithGoogle
End Sub

Sub btnSignOut_Click
   auth.SignOutFromGoogle
   lblName.Text = "Goodbye!"
End Sub

Sub Auth_SignedIn (User As FirebaseUser)
   Log("SignedIn: " & User.DisplayName)
   lblName.Text = "Hello: " & User.DisplayName
End Sub

Next:
- Combine Google and Facebook: https://www.b4x.com/android/forum/t...seauth-to-support-facebook.67954/#post-430482
- Server verification of signed in users: https://www.b4x.com/android/forum/t...end-authentication-for-signed-in-users.68672/

FirebaseAuth is an internal library now. It is preinstalled with the IDE.

V2.01 is attached. It adds a SignError (Error As Exception) event.
 

Attachments

  • FirebaseAuth_Example.zip
    11.7 KB · Views: 2,727
  • FirebaseAuth.zip
    11.1 KB · Views: 1,139
Last edited:

wimpie3

Well-Known Member
Licensed User
Longtime User
Does this library work on Android 2.2? My app crashes at startup and doesn't even display a message in the console (and B4A returns the error the debugger cannot connect).
 

wimpie3

Well-Known Member
Licensed User
Longtime User
This is what I've found:

Version 10.0.0 of the Google Play services client libraries, as well as the Firebase client libraries for Android, will be the last version of these libraries that support Android API level 9 (Android 2.3, Gingerbread). The next scheduled release of these libraries, version 10.2.0, will increase the minimum supported API level from 9 to 14 (Android 4.0.1, Ice Cream Sandwich). This change will happen in early 2017.

I absolutely need Firebase Auth on Android 2.3 :-( What are my possibilities?
 

wimpie3

Well-Known Member
Licensed User
Longtime User
@Erel Here you clearly mention "The minimum version of most features is 2.3 (API 9)." Can you please shine your light on this subject? How can I use Firebase auth with 2.3?
 

Angel Garcia

Member
Licensed User
Why does this happen with Facebook that some emails are not displayed?
Hi Desof,
How did you resolved this?
Same issue here, already set "Allow creation of multiple accounts with the same email address " option off, with no luck.
Thanks in advance!
 

desof

Well-Known Member
Licensed User
Longtime User
I do not understand your question

!

Facebook in your help says this
Please note that requesting the email permission does not guarantee that you will get an email address. For example, if someone logs into Facebook with a phone number instead of with an email address, this field may be empty.
 

Leni Berry

Active Member
Licensed User
Longtime User
i cannot sign in with google now. but i can still sign in with facebook... it 's weird because i didnt change anything i guess.. and firebase autentication is fine works before both google and facebook...

No error found in the log...

But i attach unfilter logs that i didnt know where to find it.. please help me...
 

Attachments

  • error signin with google.txt
    375.4 KB · Views: 454

Leni Berry

Active Member
Licensed User
Longtime User
There is no JAVA_OPTS in B4A. You need to change MaxRamForDex in the ini file.

yes... i already set long time ago for MaxRamForDex=1024 in C:\Users\[user]\AppData\Roaming\Anywhere Software\Basic4android\b4xV5.ini

tq so much
 

BarryW

Active Member
Licensed User
Longtime User
This library requires B4A v6+.

It allows the users to sign in to your app with their Google account (more identity providers will be added in the future).

View attachment 44939

Like all Firebase services it is quite simple to integrate this service in your app.

1. Follow this tutorial and make sure to add the Firebase Auth manifest snippet: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

2. This service requires that the signing key SHA1 signature is set in the Firebase project settings:

SS-2016-06-13_16.36.56.png


You can find this value under Tools - Private Sign Key, in the signature field:

SS-2016-06-13_16.38.08.png


Initialize the FirebaseAuth object and call SignInWithGoogle to sign in. Note that the user will be signed in automatically when the program restarts.
B4X:
Sub Process_Globals
   Private auth As FirebaseAuth
End Sub

Sub Globals
   Private lblName As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     auth.Initialize("auth")
   End If
   Activity.LoadLayout("1")
   If auth.CurrentUser.IsInitialized Then Auth_SignedIn(auth.CurrentUser)
End Sub

Sub btnSignIn_Click
   auth.SignInWithGoogle
End Sub

Sub btnSignOut_Click
   auth.SignOutFromGoogle
   lblName.Text = "Goodbye!"
End Sub

Sub Auth_SignedIn (User As FirebaseUser)
   Log("SignedIn: " & User.DisplayName)
   lblName.Text = "Hello: " & User.DisplayName
End Sub

Next:
- Combine Google and Facebook: https://www.b4x.com/android/forum/t...seauth-to-support-facebook.67954/#post-430482
- Server verification of signed in users: https://www.b4x.com/android/forum/t...end-authentication-for-signed-in-users.68672/

Where to put the authorized users list?
 
Status
Not open for further replies.
Top