Skip to navigation

Use this guide to open an IDMe OAuth 2.0 flow from an Android app in the system browser. Read the native app integrations overview first.

Don’t load IDMe in an Android WebView. Use AppAuth for Android, Auth Tab, or Custom Tabs as described below.

Choose an approach

ApproachWhen to use it
AppAuth for Android (recommended)Handles Custom Tabs, PKCE, state, and redirect handling for you.
Auth TabChrome’s authentication-specific Custom Tab. Returns the redirect directly to your activity. Falls back to a Custom Tab when unavailable.
Custom TabsWorks on any browser that supports Custom Tabs. Receive the redirect with an app link or custom scheme.

Add the AndroidX Browser library for Auth Tab or Custom Tabs:

build.gradle.kts
dependencies {
implementation("androidx.browser:browser:1.9.0")
}

Option 1: AppAuth for Android

build.gradle.kts
dependencies {
implementation("net.openid:appauth:0.11.1")
}
Start the IDMe request with AppAuth
val serviceConfig = AuthorizationServiceConfiguration(
Uri.parse("https://api.id.me/oauth/authorize"),
Uri.parse("https://api.id.me/oauth/token")
)
val request = AuthorizationRequest.Builder(
serviceConfig,
CLIENT_ID,
ResponseTypeValues.CODE,
Uri.parse("https://example.com/idme/callback")
)
.setScope("YOUR_SCOPE")
.build() // AppAuth adds PKCE and state automatically.
val authService = AuthorizationService(this)
val launcher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
val response = AuthorizationResponse.fromIntent(result.data!!)
val error = AuthorizationException.fromIntent(result.data)
// Exchange response.authorizationCode with your backend,
// or call authService.performTokenRequest(response.createTokenExchangeRequest()).
}
launcher.launch(authService.getAuthorizationRequestIntent(request))

Replace YOUR_SCOPE with your policy scope, and use the sandbox endpoints when testing.

Option 2: Auth Tab with Custom Tab fallback

Auth Tab opens a browser tab built for authentication and returns the redirect result directly to your app.

Launch IDMe in Auth Tab
private val authTabLauncher =
AuthTabIntent.registerActivityResultLauncher(this, ::handleAuthResult)
fun startIdmeSignIn(authorizationUri: Uri) {
val browser = CustomTabsClient.getPackageName(this, null)
if (browser != null && CustomTabsClient.isAuthTabSupported(this, browser)) {
AuthTabIntent.Builder().build().launch(
authTabLauncher,
authorizationUri,
"example.com", // Host of your https redirect URI
"/idme/callback" // Path of your https redirect URI
)
} else {
// Fall back to a Custom Tab and receive the redirect with an app link.
CustomTabsIntent.Builder().build().launchUrl(this, authorizationUri)
}
}
private fun handleAuthResult(result: AuthTabIntent.AuthResult) {
when (result.resultCode) {
AuthTabIntent.RESULT_OK -> handleRedirect(result.resultUri!!)
AuthTabIntent.RESULT_CANCELED -> showSignInCanceled()
else -> showSignInError()
}
}

To use a custom scheme redirect with Auth Tab instead, pass the scheme, such as launch(authTabLauncher, authorizationUri, "com.example.app").

Launch IDMe in a Custom Tab
fun startIdmeSignIn(authorizationUri: Uri) {
CustomTabsIntent.Builder()
.setShowTitle(true)
.build()
.launchUrl(this, authorizationUri)
}

Declare an app link for your redirect URI so Android sends the redirect back to your app instead of opening it in the browser.

AndroidManifest.xml
<activity
android:name=".IdmeCallbackActivity"
android:exported="true"
android:launchMode="singleTask">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="example.com"
android:pathPrefix="/idme/callback" />
</intent-filter>
</activity>

Publish a Digital Asset Links file at https://example.com/.well-known/assetlinks.json so Android can verify that your app owns the domain. See Verify Android App Links.

Handle the redirect
class IdmeCallbackActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent.data?.let(::handleRedirect)
finish()
}
}
fun handleRedirect(uri: Uri) {
val returnedState = uri.getQueryParameter("state")
if (returnedState != savedState) return showSignInError()
uri.getQueryParameter("error")?.let { return showSignInError() }
val code = uri.getQueryParameter("code") ?: return showSignInError()
exchangeCode(code, savedCodeVerifier)
}

Camera permissions

When IDMe runs in Auth Tab or a Custom Tab, the browser requests camera access for document, selfie, and liveness capture, including in-page capture by the IDMe Legal ID and face verification SDKs. Your app doesn’t need the CAMERA permission, a file chooser, or an onPermissionRequest handler for IDMe capture steps. Don’t switch to a WebView for camera steps.

Testing checklist

  • The authorization URL opens in Auth Tab or a Custom Tab, not a WebView.
  • The fallback path works on a device whose default browser doesn’t support Auth Tab.
  • The app link opens your app directly. Run adb shell pm get-app-links com.example.app and confirm the domain shows verified.
  • A member can sign in with a passkey.
  • Document capture, selfie capture, and liveness checks complete on a physical device.
  • Pressing back or closing the tab returns the member to a recoverable screen.
  • A redirect with a mismatched state is rejected.