B4A Library Facebook - Extends FirebaseAuth to support Facebook

This library requires B4A v6+.


This library together with FirebaseAuth allows users to sign in to your app with a Facebook or Google account.

Start with configuring FirebaseAuth: https://www.b4x.com/android/forum/threads/firebaseauth-authenticate-your-users.67875/
Once it works you can follow these instructions to add support for Facebook.

You should create a facebook app with an Android platform:

Enable Facebook in Firebase console: Auth - Sign In Method:

Add the OAuth redirect URI from Firebase to Facebook Login product:

You will need to follow these instructions to create a hash key from B4A signing key: https://developers.facebook.com/docs/android/getting-started#release-key-hash
The alias in the command should be B4A.

Add the following snippet to the manifest editor:
'************ Facebook Login ****************
AddApplicationText( <activity
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />
          <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>)

'************ Facebook Login (end) **********
CreateResource(values, facebook.xml, <resources>
    <string name="facebook_app_id">123123123123</string>
Replace the number with your Facebook app id.

The code itself is simple. You need to initialize FacebookSdk in the starter service.
Call SignIn from an Activity to sign in.
Note that the user will sign in automatically after the first time.

Auth_SignedIn event is raised after the user signs in.

Firebase instructions: https://firebase.google.com/docs/auth/android/facebook-login
Facebook instructions: https://developers.facebook.com/docs/facebook-login/android

Note that you need to "make the app public" before other users can log in:



v1.04 - Based on Facebook 11.2
v1.02 - Based on Facebook SDK 7.0.0.
v1.01 - Based on Facebook SDK 5.50. It depends on AppCompat which should be added in the libraries tab.

Download link: http://www.b4x.com/android/files/Facebook-11.2.0.zip


  • FacebookExample.zip
    54.7 KB · Views: 177
Last edited: