1

My app uses google sign-in. I manually generated the google-services.json using google console (NOT from android studio / firebase / etc).

At the moment, while I don't explicitly use any firebase service, I see firebase-related messages during my app init.

I would like to integrate ONLY Firebase realtime database, and I wonder if it will conflict with my current auth scheme based on Google Sign-In solely. Refactoring all the auth related logic is not something we can afford at the moment, and I remember a lot of pain with google libraries version / gradle / app plugin as our project integrates more than 30 library projects.

Ideally, I should be able to access the Firebase Database using the google credentials I already have, and avoiding as much as possible duplicating the auth logic with "frebase-auth" libraries.

These are my only google services - related dependencies of the project:

dependencies {
    compile 'com.google.android.gms:play-services-auth:10.2.1'
}
apply plugin: 'com.google.gms.google-services'

And this is my minimal google-services.json that I use for Google Sign In.

{
  "project_info": {
    "project_number": "xxxx",
    "project_id": "yyyy"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:xxxx:android:yyy",
        "android_client_info": {
          "package_name": "tv.xxx.mini"
        }
      },
      "oauth_client": [
        {
          "client_id": "xxx.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "xxx.mini",
            "certificate_hash": "xxx"
          }
        },
        {
          "client_id": "xxx.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "xxxxx"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 1
        }
      }
    }
  ],
  "configuration_version": "1"
}
rupps
  • 9,712
  • 4
  • 55
  • 95

1 Answers1

2

For the Firebase database you will to have a firebase_url setting in the project_info node:

"firebase_url": "https://yourprojectname.firebaseio.com",

If you'd rather not modify your google-services.json you can also specify the URL in your code when the app starts as shown in my answer here: How to connect to more than one firebase database from an android App.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Thanks a lot Frank. I already had read that detailed post you mention and was considering it. It makes a lot of sense to me to setup a tiny project to interface with FB services then access it from the legacy projects. One thing though, what about the auth? Will I have to keep separate user lists in-sync (Firebase USers / my google signed-in users?) – rupps Mar 11 '18 at 15:35
  • 1
    Google sign-in users are automatically (re)created in Firebase when you authenticate with them for the first time. – Frank van Puffelen Mar 11 '18 at 16:12