DEVELOPERS BLOG

Supporting All Firebase Sign-in Methods with BlackBerry Spark Communications Services SDK

If you are currently using Firebase Auth in your app, you should know that it is quick and easy to integrate with the BlackBerry Spark Communications Services SDK. All while using your existing and preferred sign-in method! Although we already provide support libraries for integration with Google using OAuth2.0, Firebase offers many more sign-in methods including email/password, phone, anonymous, etc. These different sign-in methods can all be used by simply passing a Firebase JWT token to our SDK, and then configuring your domain to use the Firebase JWKS URI. Read on to find out how!

Fetching a JWT Token from Firebase

When a user is signed in with Firebase Auth, they will be issued a corresponding JWT token which we can re-use to authenticate users for BlackBerry Spark Communications Services. Depending on your platform, you can fetch the user’s JWT token from Firebase by calling a few simple APIs.

 

Passing the JWT Token to BlackBerry Spark Communications Services

Once you have the auth token from Firebase, you can pass it to the SDK. On iOS this would be via the sendAuthToken API and an example of it would be:

BBMEnterpriseService.shared()?.sendAuthToken(idToken!, userIdentifier:

Auth.auth().currentUser!.uid, setupStateBlock: { (authTokenState, setupState, regId) in ….}

 

Configuring Your App in BlackBerry’s Application Portal

Finally, head over to account.blackberry.com to fill in the details of your configuration. From our site, open your BlackBerry Spark Communications app, and then under the ‘Communications Services’ tab, you will see a section to input details for your identity provider. To verify Firebase JWT tokens, we will be using the OpenID connect protocol. Select this tab, and then fill out the fields as follows:

·       JWKS URI is provided by Google at the following address: https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com

·       Issuer will be https://securetoken.google.com/<your Firebase project id>

·       The JWT Field names are:

o   User ID: sub

o   Expiry: exp

o   ClientID: aud

o   Issuer: iss

·       Finally, your Client ID will be your Firebase project ID, which you can find by going to your Firebase console, and then navigating to Project Settings.

And that’s it! Once you’ve set this up, you’ll be able to authenticate users with the SDK and use all the wonderful messaging, voice, video, file transfers, and data connection APIs that we provide out of the box. If you have any questions or comments about BlackBerry Spark Communications Services or other BlackBerry related technologies, check out the BlackBerry Forums.

Gurjit Ghangura

About Gurjit Ghangura

Enterprise Solutions Developer, Love BlackBerry, Developer at Heart.


Jeff J.

About Jeff J.

As a part of the Enterprise Solutions Team, I work to bring the latest BlackBerry software and security features to life on the Android platform.