DefaultWebAuthenticationProvider

class DefaultWebAuthenticationProvider @JvmOverloads constructor(eventCoordinator: EventCoordinator = EventCoordinator(emptyList()), val preferredBrowsers: List<String> = DEFAULT_PREFERRED_BROWSERS, val queryIntentServicesFlags: Int = 0, customizeTabsIntent: (context: Context, builder: CustomTabsIntent.Builder) -> Unit? = null, customizeAuthTabIntent: (context: Context, builder: AuthTabIntent.Builder) -> Unit? = null, browserSelector: BrowserSelector = defaultBrowserSelector(eventCoordinator, preferredBrowsers, queryIntentServicesFlags)) : WebAuthenticationProvider, AuthTabWebAuthenticationProvider

Default WebAuthenticationProvider implementation that launches the OIDC redirect flow using Chrome Custom Tabs, preferring Chrome's Auth Tab (a Custom Tabs variant purpose-built for auth redirect flows) when the resolved browser supports it.

Browser selection and tab appearance are configured via constructor parameters rather than event handlers. Use preferredBrowsers to control which browser is chosen, queryIntentServicesFlags to adjust the package-manager query, browserSelector to fully override browser selection, customizeTabsIntent to style the Chrome Custom Tab (toolbar color, animations, close button icon, etc.), and customizeAuthTabIntent for the equivalent Auth Tab customization.

val provider = DefaultWebAuthenticationProvider(
preferredBrowsers = listOf("com.android.chrome"),
customizeTabsIntent = { context, builder ->
builder.setToolbarColor(ContextCompat.getColor(context, R.color.brand_primary))
}
)
val webAuth = WebAuthentication(client, provider)

Constructors

Link copied to clipboard
constructor(eventCoordinator: EventCoordinator = EventCoordinator(emptyList()), preferredBrowsers: List<String> = DEFAULT_PREFERRED_BROWSERS, queryIntentServicesFlags: Int = 0, customizeTabsIntent: (context: Context, builder: CustomTabsIntent.Builder) -> Unit? = null, customizeAuthTabIntent: (context: Context, builder: AuthTabIntent.Builder) -> Unit? = null, browserSelector: BrowserSelector = defaultBrowserSelector(eventCoordinator, preferredBrowsers, queryIntentServicesFlags))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The list of browser package names to prefer when selecting which Chrome Custom Tabs implementation is used. Checked in order; the first installed match wins.

Link copied to clipboard

Flags passed to android.content.pm.PackageManager.queryIntentServices when querying for Chrome Custom Tabs intent services. Ignored if browserSelector is overridden.

Functions

Link copied to clipboard
open override fun launch(context: Context, url: HttpUrl): Exception?

Launches the OIDC redirect flow associated with a WebAuthentication.

Link copied to clipboard
open override fun launchAuthTab(context: Context, url: HttpUrl, redirectUrl: String, launcher: ActivityResultLauncher<Intent>): Result<Unit>

Launches the OIDC redirect flow via Auth Tab, or falls back to WebAuthenticationProvider.launchCustomTab if the resolved browser doesn't support it.

Link copied to clipboard
open override fun launchCustomTab(context: Context, url: HttpUrl): Result<Unit>

Launches the OIDC redirect flow associated with a WebAuthentication and wraps launch success/failure in a Result.