Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify default_web_client_id at runtime #1911

Closed
edenman opened this issue Feb 9, 2021 · 6 comments
Closed

Add ability to specify default_web_client_id at runtime #1911

edenman opened this issue Feb 9, 2021 · 6 comments

Comments

@edenman
Copy link
Contributor

edenman commented Feb 9, 2021

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.

@samtstern
Copy link
Contributor

@edenman thank you for this, I think this is a reasonable feature request.

@samtstern
Copy link
Contributor

This was fixed and released in version 7.2.0

@edenman
Copy link
Contributor Author

edenman commented Jun 14, 2021

@samtstern thanks! I don't see any method on GoogleSignInOptions.Builder to set this value in play-services-base:17.1.0. Was the associated change not released in that library yet?

@edenman
Copy link
Contributor Author

edenman commented Jun 14, 2021

com.google.firebase:firebase-auth:21.0.1
depends on
com.google.android.gms:play-services-auth-api-phone:17.4.0
depends on
com.google.android.gms:play-services-base:17.1.0

...looks like there's a 17.6.0 of play-services-base but even if I force update that library, I still don't see a setter for it? Although the code obfuscation is making it hard to tell. What's the method supposed to be called?

@edenman
Copy link
Contributor Author

edenman commented Jun 14, 2021

oh wow is it requestIdToken()?

@samtstern
Copy link
Contributor

samtstern commented Jun 15, 2021

@edenman yep it's requestIdToken(), that's the only place that Client ID was ever used. The "web client ID" is needed in order to make sure the audience on the ID token is correct so that Firebase Auth can validate it when you call signInWithCredential

You can see here how it's used when you're not using FirebaseUI:
https://firebase.google.com/docs/auth/android/google-signin#authenticate_with_firebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants