FirebaseUI-Android icon indicating copy to clipboard operation
FirebaseUI-Android copied to clipboard

Feature request: Support any OpenID Connect Provider

Open alex-kor opened this issue 2 years ago • 3 comments

environment

  • Android device: Google Pixel 4 XL
  • Android OS version: 13
  • Google Play Services version: 20.3.0
  • Firebase/Play Services SDK version: 4.3.15
  • FirebaseUI version: 8.0.2

the problem:

Making a connection to OIDC provider which is added through Firebase console App crashes when assembling list of Providers using provider builder: AuthUI.IdpConfig.GenericOAuthProviderBuilder("oidc.provider-id","provider-name", R.layout.oidc_button).build(),

Steps to reproduce:

  1. Create a Firebase project
  2. Add Authentication with Google
  3. Add OIDC provider as a sign in method
  4. On Android Platform try to create a list of providers using GenericOAuthProviderBuilder
  5. Observe the crash

Observed Results:

logcat: FATAL EXCEPTION: main Process: com.tmobile.authentication, PID: 9550 java.lang.IllegalArgumentException: Unknown provider: oidc.provider-id at com.firebase.ui.auth.AuthUI$IdpConfig$Builder.(AuthUI.java:635) at com.firebase.ui.auth.AuthUI$IdpConfig$GenericOAuthProviderBuilder.(AuthUI.java:1251)

Expected Results:

App should not crash and should open a dialog showing my OIDC provider in a list of sign-in buttons

Relevant Code:

val providers = arrayListOf(
      AuthUI.IdpConfig.GoogleBuilder().build(),
      AuthUI.IdpConfig.GenericOAuthProviderBuilder("oidc.provider-id","provider-name", R.layout.oidc_button).build()
  )
  val signInIntent = AuthUI.getInstance()
      .createSignInIntentBuilder()
      .setAvailableProviders(providers)
      .build()
val firebaseSignInLauncher = rememberLauncherForActivityResult(
      contract = FirebaseAuthUIActivityResultContract(),
      onResult = {
          onFirebaseUiLogin(it.idpResponse)
      }
  )

... later in a code ...
firebaseSignInLauncher.launch(signInIntent)

alex-kor avatar Jun 07 '23 14:06 alex-kor

Hi Rosario. Any updates on this issue? Do you have any possible ideas when you think you can fix it?

alex-kor avatar Jun 20 '23 14:06 alex-kor

Hi @alex-kor, GenericOAuthProviderBuilder is not a documented API, and is not currently meant to be used to implement custom OIDC providers. The parent constructor for GenericOAuthProviderBuilder explicitly checks that the ID provided is one that is intended to be used in FirebaseUI: https://github.com/firebase/FirebaseUI-Android/blob/5b6c9f01f5a674d754d8e9b1242197fe040086e7/auth/src/main/java/com/firebase/ui/auth/AuthUI.java#L632-L638

Supported providers are: https://github.com/firebase/FirebaseUI-Android/blob/5b6c9f01f5a674d754d8e9b1242197fe040086e7/auth/src/main/java/com/firebase/ui/auth/AuthUI.java#L118-L140

Adding the ability to set any OIDC provider sounds like a useful feature request, so I've added the feature request label to this issue. In the meantime you'll need to fork the library if you want to modify it to support a custom OIDC provider.

jhuleatt avatar Jun 27 '23 16:06 jhuleatt