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,731
  • FirebaseAuth.zip
    11.1 KB · Views: 1,142
Last edited:

jazzzzzzz

Active Member
Licensed User
Longtime User
I have initialised in Starter Service_Create, now when I log out and login the success event callback came more than 1 time for a single login click..
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
v1.02 was uploaded to the first post. It adds a GetUserTokenId method. This method retrieves a temporary token id that can be used to verify the user on your backend server: https://www.b4x.com/android/forum/t...ckend-verification-for-signed-in-users.68672/

B4X:
Sub Auth_SignedIn (User As FirebaseUser)
   Log("SignedIn: " & User.DisplayName)
   CallSub(Main, "SetState")
   Log(User.Uid)
   Log(User.Email)
   auth.GetUserTokenId(User, False)
End Sub

Sub Auth_TokenAvailable (User As FirebaseUser, Success As Boolean, TokenId As String)
   Log(TokenId)
   'send tokenid to server
End Sub
 

Daniel-White

Active Member
Licensed User
Longtime User
Hi folks.

Firebase Auth, has the service to auth using Email/Password (simple without Oauth). Can I use this firebase lib of B4A not for use Oauth , I would like to use the simple Email and password to give access to firebase Storage.


or?? another way to accomplish my idea.

Can I use this lib, and always give the same credentials to access the firebase storage, using Oauth?, I know it is bad idea put passwords etc in hardcode. the idea is allow my APP to send anonymous information to File server (and don't bother the end user to ingress credentials), I would like the APP upload files without need ask credentials to end user , anyway, it will be anonymous information in the firebase storage.

Thanks youuuuuuuuuuuuuuu:D
 

awakenblueheart

Member
Licensed User
Longtime User
I got "connection failed." on the log. Help me to configure pleazzz...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Firebase Auth, has the service to auth using Email/Password (simple without Oauth). Can I use this firebase lib of B4A not for use Oauth , I would like to use the simple Email and password to give access to firebase Storage.
B4A FirebaseAuth currently supports two authentication methods: Google and Facebook. There is no support for email / password authentication.

Please start a new thread for the question about FirebaseStorage.
 

islander

Member
Licensed User
Is there any chance or plan on supporting email/password authentication sooner or later though? :)

I would love to have it too.

B4A FirebaseAuth currently supports two authentication methods: Google and Facebook. There is no support for email / password authentication.

Please start a new thread for the question about FirebaseStorage.
 
D

Deleted member 103

Guest
You can find this value under Tools - Private Sign Key, in the signature field:
but I can not find "sha1", I only have this view.

keystore.JPG
 

jtare

Active Member
Licensed User
Longtime User
Erel, do I need my own server to authenticate users? It is possible to create some type of list in the firebase console to only allow user that I manually input?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

fredo

Well-Known Member
Licensed User
Longtime User
Edit: Now integrated by @DonManfred in the Auth lib. See here

_____
...(more identity providers will be added in the future).

Will the new Sign-In provider Firebase Anonymous Authentication be available in the near future?

09-10-_2016_09-15-40.jpg

As introduced by the Firebase Team here it comes with many advantages for the developer and user:
  • A user can be logged in programmaticaly without asking him for credentials
  • The user will be identified for all Firebase services by means of an universal identifier (uid)
  • Later this uid can be merged with any other Login method
09-10-_2016_09-40-06.jpg
 
Last edited:

johndb

Active Member
Licensed User
Longtime User
Will the new Sign-In provider Firebase Anonymous Authentication be available in the near future?


As introduced by the Firebase Team here it comes with many advantages for the developer and user:
  • A user can be logged in programmaticaly without asking for credentials
  • The user will be identified for all Firebase services by means of a universal identifier (uid)
  • Later this uid can be merged with any other Login method
+1 on adding this feature to the B4A Library. This would be extremely useful for my current apps in development.
Additionally, any progress on when email / password authentication will be available?

Thank you,

John
 

DonManfred

Expert
Licensed User
Longtime User
+1 on adding this feature to the B4A Library

Erel gave me the source of the lib so i can add them ;-)
I m working on it...

Additionally, any progress on when email / password authentication will be available?
Will check to add this too :D
 
Status
Not open for further replies.
Top