Skip to main content
This guide provides an overview of how to get started integrating the WebAuthn passkey factor in Android apps, for secure web-based authentication. On Android, AuthTab is part of the Android Browser library that enables apps to authenticate users via a web service, presenting a secure and user-friendly popup browser for login flows.

Setup

  1. Add the necessary dependencies to your app’s build.gradle.kts file:
  1. Define your custom URL scheme in your AndroidManifest.xml:

Full code example

Automatic fallback mechanism

The androidx.browser.auth.AuthTabIntent library automatically handles the fallback to CustomTabs if AuthTab is not supported on the device. You don’t need to implement any custom logic for this fallback – the library takes care of it. However, there are differences in how the redirect URL is handled:
  1. When using AuthTab directly, the result comes back through the handleAuthResult callback.
  2. When the library falls back to CustomTabs, the result comes back through your activity’s onNewIntent method.
Therefore, it’s important to implement both methods to handle both cases.

Usage example

To use the authentication in your app:

Notes

  • Replace CONST_BASE_URL with your backend authentication URL.

Troubleshooting

  • If the callback URL doesn’t trigger your app, ensure the URL scheme in your manifest matches exactly with what you’re using in the code.
  • Make sure your Android manifest has the correct intent filter for handling the callback URL.
  • If authentication fails, check the logs for detailed error information.