BlackBerry Spark Communications Services Guide

Configuring Android Examples to use Google Sign-In and Google People

The SDK RichChat example application for Android can be configured to integrate with Google Sign-In as your identity provider and Google People for user management.

This page guides you through the changes you can make to the RichChat example to integrate with Google Sign-In and Google People using the Support library. See the Google Sign-In Identity Provider guide for help on setting up a Firebase project to use with the SDK.

Extract the SDK Package

Google Configuration

Before running the example applications with Google Sign-In and Google People, you must first configure those services for the example you wish to run.

  1. First, configure Google Sign-In as your Identity Provider.
  2. Next, configure Google People for User Management.

Gradle Configuration

The build.gradle for the RichChat application copies the configuration values from the file into build config fields or resource strings. The file must include all of the values listed below.

# Your application's domain ID

# Signing key store info:
# Password used when creating Android signing key store
# Password used when creating app signing key
# Alias used when creating app signing key
# Path to your Android signing key store

# For Google Sign-In:
# The client_id (client_type: 3) value in your google-services.json
# The client secret value from the Web Client OAuth 2.0 credentials

When adding an Android application in the Firebase console, you must provide the package name and signing SHA-1 fingerprint value for your application. To generate the SHA-1 fingerprint, run the Gradle signingReport task. You must use the same key store when you create any build (release or debug) that is authenticating with this Firebase project.

Save the provided google-services.json file in the app directory of the RichChat example. Set the client_server_id value in the file with the client_id value from the google-services.json file.

"oauth_client": [
        "client_id": "",
        "client_type": 3

Copy the Web client secret value from the Firebase Google Sign-In configuration into the client_secret field. The client secret is required to authenticate with the Google People API.

Building the Application

The Support library includes authProvider flavors for Azure and Google. The RichChat application is configured to support both Azure and Google flavors.

You can specify the build variant in Android Studio or use a Gradle command to build the RichChat example with the Google product flavor.

gradle assembleGoogleDebug

Included Libraries

The Google flavor of the Support library includes the firebase-auth and play-services-auth libraries for Google Sign-In and Firebase authentication. The firebase-database library is included to enable cloud key management using Firebase Database. The google-api-services-people library is included to enable Google People API support.

// Include Google play services auth module.
googleImplementation ''
// needed for firebase DB to store user management
googleImplementation ''
// needed for firebase DB rules checking auth to work
googleImplementation ''
// Google People API for contact management
googleImplementation ''

Key Management

BlackBerry Key Management Service

To use the BlackBerry Key Management Service set the USE_KMS build config field to true in the application build.gradle file.

// Use BlackBerry KMS to store cryptographic security keys
buildConfigField("boolean", "USE_KMS", "true")

Cloud Key Storage

If your application needs complete control of its cryptographic security keys, you can secure these keys by using Firebase for Cloud Key Storage.

To use Cloud Key Storage with Firebase, set the USE_KMS build config field to false in the application build.gradle file. Follow the Firebase for Cloud Key Storage guide to create a database with the appropriate rules.

// To use Cloud Key Storage, set this to false.
buildConfigField("boolean", "USE_KMS", "false")

The Support library code for Cloud Key Storage in Firebase is compatible across iOS, Android, and JavaScript.