Edit: It is recommended to use FirebaseAuth for new projects:
FirebaseAuth - Authenticate your users
This library wraps Google Identity Toolkit SDK: https://developers.google.com/identity/toolkit/
Currently it only supports signing with Google accounts.
Using this library requires some configuration.
1. Carefully follow the instructions under Step 2: https://developers.google.com/ident...p_2_configure_the_google_identity_toolkit_api
You can find the sha1 signature in the private sign key dialog:
2. Add the following code to the manifest editor:
You need to replace the two marked keys.
3. Add the following attributes:
The code itself is simple:
The library is attached. Make sure to copy all files including the folder to the additional libraries folder.
FirebaseAuth - Authenticate your users
This library wraps Google Identity Toolkit SDK: https://developers.google.com/identity/toolkit/
Currently it only supports signing with Google accounts.
Using this library requires some configuration.
1. Carefully follow the instructions under Step 2: https://developers.google.com/ident...p_2_configure_the_google_identity_toolkit_api
You can find the sha1 signature in the private sign key dialog:
2. Add the following code to the manifest editor:
B4X:
AddApplicationText(
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="identitytoolkit.show_providers"
android:value="Google" />
<meta-data
android:name="identitytoolkit.use_google_plus"
android:value="false" />
<meta-data
android:name="identitytoolkit.api_key"
android:value="*** API keys Type = Android ***" />
<meta-data
android:name="identitytoolkit.server_client_id"
android:value="*** OAuth 2.0 client IDs Type = Web application ***" />
<meta-data
android:name="identitytoolkit.server_widget_url"
android:value="/" />
)
3. Add the following attributes:
B4X:
#AdditionalRes: $AndroidSDK$\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#AdditionalRes: $AdditionalLibs$\extra-res\identity, com.google.identitytoolkit
#ExcludeClasses: .games, .drive, .fitness, .wearable, .measurement, .cast, .nearby, .maps
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .vision, .gcm
#ExcludeClasses: .ads
The code itself is simple:
B4X:
Sub Process_Globals
End Sub
Sub Globals
Private gi As IdentityClient
Private lblUsername As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
gi.Initialize("gi")
End Sub
Sub btnSignin_Click
gi.StartSignin
End Sub
Sub gi_Signin (Success As Boolean, User As IdentityUser)
If Success Then
Log($"Name: ${User.DisplayName}"$)
Log($"Email: ${User.Email}"$)
Log($"Photo: ${User.PhotoUrl}"$)
lblUsername.Text = $"Username: ${User.DisplayName}"$
Else
Log("Error")
End If
End Sub
The library is attached. Make sure to copy all files including the folder to the additional libraries folder.
Attachments
Last edited: