Skip to content

Native apps and biometrics

You can add biometric sign-in to a mobile app using standard OpenID Connect and OAuth, without an authN SDK.

Mobile apps should open the project’s sign-in page in the system browser, as RFC 8252 recommends. On iOS that means ASWebAuthenticationSession, and on Android it means Custom Tabs. Libraries such as AppAuth (for iOS and Android) and expo-auth-session handle this for you.

Use the authorization code flow with PKCE, and a redirect URI that belongs to your app, such as com.example.app:/callback.

Passkeys work there with nothing extra to do, because the browser shows the device’s own Face ID or fingerprint prompt.

DPoP (RFC 9449) ties an app’s tokens to a key that never leaves the phone. If you keep that key in the phone’s secure hardware and make it usable only after Face ID or a fingerprint, then every time the app opens, the person confirms with their biometric, the app signs a proof with the key, and it refreshes its tokens. A refresh token copied off the device is useless anywhere else.

  1. Create a P-256 key in secure hardware that needs a biometric to use. On iOS, use the Secure Enclave with .biometryCurrentSet. On Android, use the Keystore with setUserAuthenticationRequired(true), and StrongBox where the device has it.
  2. When you exchange the authorization code, include a DPoP header containing a JWT signed with that key. Its header is {"typ":"dpop+jwt","alg":"ES256","jwk":<public key>}, and its body is {"jti":<random>,"htm":"POST","htu":"<issuer>/oauth2/token","iat":<now>}.
  3. The response says "token_type": "DPoP". The access token contains the key’s thumbprint in cnf.jkt, and for a native app the refresh token is bound to the key as well.

Unlock the key with the person’s biometric, sign a fresh proof, and refresh. Without the key, the refresh is refused with invalid_dpop_proof, and the failed attempt doesn’t use up the refresh token.

Send Authorization: DPoP <access token> together with a new proof for that request. The proof’s claims are htm, htu, and ath, which is the base64url SHA-256 hash of the access token. Your project’s userinfo endpoint and the Admin API both refuse a DPoP-bound token that’s sent as Bearer.

In an application’s token settings, Require DPoP means tokens are only issued when a proof is sent.

Under Sessions and tokens, Require DPoP nonces (RFC 9449 §8) means proofs must include a nonce that authN gave out, so they can’t be prepared in advance. When a proof is missing one, the response is use_dpop_nonce with the nonce in a DPoP-Nonce header, and the app retries once with it. Standard libraries handle this for you.

You can also bind the authorization code itself to the key by adding dpop_jkt=<thumbprint> to the authorization request (RFC 9449 §10).

Proofs can be signed with ES256, EdDSA, RS256 or PS256, and are accepted for 60 seconds either side of their iat.

Accept a token that contains cnf.jkt only if all of the following are true:

  1. The request uses Authorization: DPoP.
  2. The DPoP header contains a single JWT with typ set to dpop+jwt, signed with an asymmetric algorithm by the jwk in its header.
  3. That key’s RFC 7638 thumbprint is the same as cnf.jkt.
  4. htm and htu match the request, ignoring the query string.
  5. iat is recent.
  6. ath is the hash of the access token.
  7. You haven’t seen the same jti within that time window.

Most API frameworks’ OAuth libraries have a DPoP option that does these checks for you.