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 app.properties file into build config fields or resource strings. The app.properties file must include all of the values listed below.

# Your application's domain ID
user_domain="YOUR_DOMAIN_ID"

# Signing key store info:
# Password used when creating Android signing key store
storePassword=your_store_password
# Password used when creating app signing key
keyPassword=your_key_password
# Alias used when creating app signing key
keyAlias=your_key_alias
# Path to your Android signing key store
storeFile=../your_store_file.jks

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

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 app.properties file with the client_id value from the google-services.json file.

"oauth_client": [
    {
        "client_id": "12345678901-umrpbv07n96ck79u5uw1ow04vt4dwza.apps.googleusercontent.com",
        "client_type": 3
    }

Copy the Web client secret value from the Firebase Google Sign-In configuration into the app.properties 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 'com.google.android.gms:play-services-auth:11.4.2'
// needed for firebase DB to store user management
googleImplementation 'com.google.firebase:firebase-database:11.4.2'
// needed for firebase DB rules checking auth to work
googleImplementation 'com.google.firebase:firebase-auth:11.4.2'
// Google People API for contact management
googleImplementation 'com.google.apis:google-api-services-people:v1-rev329-1.25.0'

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.