AdamHurwitz
AdamHurwitz

Reputation: 10364

Firebase Authentication - Open Sourcing Android App

Is there a way for Firebase Authentication to work in an open sourced app without requiring an SHA-1 key?

I've open sourced the Android code for Coinverse, the first cryptocurrency news app for audiocasts on-the-go, in order to share Android best practices and architecture. The goal is for the developer to run the de-compiled app from Android Studio and login.

I've done the following for Firestore Database, Storage, YouTube API, and etc. to work as expected for developers downloading the project from GitHub:

Upvotes: 3

Views: 306

Answers (1)

AdamHurwitz
AdamHurwitz

Reputation: 10364

Shared and Private Firebase Instances

Strategy - Create both an open source shared Firebase instance to provide access to shared data and Cloud Functions, and have developers who download the GitHub project create their own private Firebase instance for authentication used as the default instance via the google-services.json file.

Pro-tip - Be sure to identify a unique SHA-1 key with each Firebase project that requires it, otherwise there'll be an authentication error outlined here.

Shared Firebase Project

  • Initialize the shared open source Firebase project with the Use multiple projects in your application programmatic implementation (separate project from the non-shared staging and production projects used for releases). - FirebaseApp.getInstance("openSourceProject") Note: setProjectId(...) also needs to be set for the FirebaseOptions although not mentioned in the link above and any other setters for services used such as Storage.
  • Populate app with public content and price data from shared Firestore project - FirebaseFirestore.getInstance(FirebaseApp.getInstance("openSourceProject"))
  • Use shared Cloud Functions and Firebase Storage to create .mp3 files from Storage .txt files and access .mp3s from Storage. - FirebaseStorage.getInstance(FirebaseApp.getInstance("openSourceProject")) and FirebaseFunctions.getInstance(FirebaseApp.getInstance("openSourceProject"))

User’s Private Firebase Project

  • Initialized as default Firebase project instance via the google-services.json file.
  • Use for authentication with their SHA-1 key
  • Save logged in user data to their Firestore instance - FirebaseFirestore.getInstance()
  • Create a Firebase token for delete user functionality

Upvotes: 1

Related Questions