Add ability to specify default_web_client_id at runtime

Step 1: Are you in the right place?

  • Yes

Step 2: Describe your environment

  • com.google.firebase:firebase-messaging:20.2.3
  • com.firebaseui:firebase-ui-auth:7.1.1

Step 3: Describe the problem:

I'm trying to push a build of my app that is capable of switching between Prod and Staging at runtime. My production API server uses one Firebase project, my staging API server uses a staging Firebase project. Following these instructions, I have managed to get the FirebaseApp.initializeApp part of this working, but AuthUI's GoogleProvider requires that default_web_client_id be set in strings.xml. This breaks me because I need to change that value at runtime. It would be great if this value could be provided at runtime.

Relevant Code:

  val providers = arrayListOf(
    AuthUI.IdpConfig.AppleBuilder().build(),
    AuthUI.IdpConfig.GoogleBuilder().build(),
    AuthUI.IdpConfig.EmailBuilder().build()
  )

ideally something like:

    val providers = arrayListOf(
      AuthUI.IdpConfig.AppleBuilder().build(),
      AuthUI.IdpConfig.GoogleBuilder().defaultWebClientID("foo").build(),
      AuthUI.IdpConfig.EmailBuilder().build()
    )

Workaround:

If anybody else hits this: you can remove the Google sign-in option when pointing at your Staging environment.