Is it possible to use Firebase's built in authentication via Google in both a web and an Android client?

1.1k views Asked by At

Following the instructions found in the Firebase docs for configuring a web client application, it says I need to create a new client app in the Google Developers Console. This is fine. However, I already have a client app defined here for my service's Android client app. Each has its own Google Console Client ID and Firebase only lets you input one client ID and client secret with in the Login & Auth section of the Firebase dashboard. Am I missing something or is supporting both web and Android client apps not possible with a single Firebase app?

2

There are 2 answers

0
Galen On

It appears this was answered in a google group.

The workflow for using Google login across multiple different application types is to create one project in the Google Developer Console with multiple separate client IDs (one for Web, one for Android, one for iOS, etc.). Make sure they all belong to the same project though! Then, in your Firebase's Dashboard, just use the client ID and Secret for your Web application. And that should be it. You don't need to tell Firebase about the Android or iOS client IDs at all and things should just work.

0
Lalit Rane On

I had two Projects created in the Google Developer Console. One serves the Android Client and another one serves the Web Client. I too faced similar issue/scenario you are facing.

Here is what worked for me. In the firebase login and auth dashboard, I used the Client Id for Android App. So now I do not have a space for giving the Client Id for Web App(which is using another Google Project). None of the Firebase auth method in Web API (except below one) worked in the Web App. But below one worked (one with oAuthToken)

ref.authWithOAuthToken("google", "<ACCESS-TOKEN>", function(error, authData) {
  if (error) {
    console.log("Login Failed!", error);
  } else {
    console.log("Authenticated successfully with payload:", authData);
  }
});