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

Feature request: Support any OpenID Connect Provider #2131

Open
alex-kor opened this issue Jun 7, 2023 · 2 comments
Open

Feature request: Support any OpenID Connect Provider #2131

alex-kor opened this issue Jun 7, 2023 · 2 comments
Assignees

Comments

@alex-kor
Copy link

alex-kor commented Jun 7, 2023

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)

@thatfiredev thatfiredev self-assigned this Jun 7, 2023
@alex-kor
Copy link
Author

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

@jhuleatt
Copy link

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:

protected Builder(@SupportedProvider @NonNull String providerId) {
if (!SUPPORTED_PROVIDERS.contains(providerId)
&& !SUPPORTED_OAUTH_PROVIDERS.contains(providerId)) {
throw new IllegalArgumentException("Unknown provider: " + providerId);
}
mProviderId = providerId;
}

Supported providers are:

public static final Set<String> SUPPORTED_PROVIDERS =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
GoogleAuthProvider.PROVIDER_ID,
FacebookAuthProvider.PROVIDER_ID,
TwitterAuthProvider.PROVIDER_ID,
GithubAuthProvider.PROVIDER_ID,
EmailAuthProvider.PROVIDER_ID,
PhoneAuthProvider.PROVIDER_ID,
ANONYMOUS_PROVIDER,
EMAIL_LINK_PROVIDER
)));
/**
* The set of OAuth2.0 providers supported in Firebase Auth UI through Generic IDP (web flow).
*/
public static final Set<String> SUPPORTED_OAUTH_PROVIDERS =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
MICROSOFT_PROVIDER,
YAHOO_PROVIDER,
APPLE_PROVIDER,
TwitterAuthProvider.PROVIDER_ID,
GithubAuthProvider.PROVIDER_ID
)));

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 jhuleatt changed the title IDP Provider not recognized when building it with GenericOAuthProviderBuilder Feature request: Support any OpenID Connect Provider Jun 27, 2023
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

3 participants