Skip to main content
Didit’s DiditAuth module signs your iOS app’s end users up and in with Didit Authentication. It opens your application’s hosted Didit page in ASWebAuthenticationSession, supports passkeys through ASAuthorization, keeps the session in the Keychain, and handles sign-out and step-up. It ships in the native SDKs since version 4.11.0, and the current release is 4.15.4.
Use a Sandbox application while you build. Every Sandbox application has Authentication turned on from the start. A Live application turns Authentication on from the Products page of the console: see Prepare your application.

Install

Add the Swift Package https://github.com/didit-protocol/sdk-ios.git at 4.15.4 and add the DiditAuth product to your target:
Package.swift
With CocoaPods, use the Auth subspec. The podspec URL embeds the git tag, which must equal the SDK version you install. Never point it at main.
Podfile
The standalone DiditAuth module needs iOS 15 and you write import DiditAuth. Every DiditSDK variant of the iOS verification SDK already includes it, and an app that installs one keeps import DiditSDK. Install one or the other, not both. The hosted pages (sign-in and step-up checks) need iOS 17.4. Below that, those calls throw browser_unavailable, and signInWithPasskey still works.

Set up the redirect and passkeys

Didit returns people to your app through an HTTPS redirect only. Custom URL schemes are not accepted.
  1. In the console, under Authentication > Security and sessions, add your redirect URL, for example https://app.example.com/didit/callback. Copy the publishable key from Authentication > Developers.
  2. Add the redirect’s host to your app’s Associated Domains as webcredentials:app.example.com, and serve https://app.example.com/.well-known/apple-app-site-association listing your app (TEAMID.bundle.id) under webcredentials. iOS checks both before it opens the page.
  3. For passkeys, register your app ID with PUT native-apps/ on the Authentication management API, and add webcredentials:<your application's Didit host> to your Associated Domains too. A redirect URL on that same Didit host also satisfies step 2.
Test on a device: the simulator does not always validate associated domains. Keep Sandbox and Live applications, their keys and their redirect URLs separate.

Sign in

The hosted sign-in is bound to its start with PKCE (S256) and a random state, and a redirect for any other sign-in is refused. Closing the page throws cancelled. Refresh tokens rotate and Didit revokes the session when a used one comes back, so every DiditAuth instance of the application refreshes under one lock and only once. A session Didit ended (revoked, expired, a reused refresh token) reads as signed out. reauthenticate asks the signed-in person to sign in again, on the hosted page or with method: .passkey, and returns their new session. It throws not_signed_in without a session and step_up_user_mismatch when a different person signs in: that new session is ended and the current one stays. Tokens stay in the Keychain on this device only (kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly). DiditSession holds userId, sessionId, applicationId, vendorData, email, emailVerified, phone, methods, mfaVerified, verified, organizations and expiresAt. vendorData is the id that ties the person to their verifications and transactions: see keep one person across products.

Verify the token on your backend

Send getToken() to your backend as a Bearer token and verify it there, against the issuer’s JWKS at <origin>/.well-known/jwks.json, before you trust it. Use a server SDK or see tokens and JWKS. Call getToken() right before each request: after a refresh, the previous access token stops working at GET session/ and DELETE session/.

Step-up before sensitive actions

.payout, .bankAccount and .contactChange follow the step-up rules of your application. When a rule applies, the identity check opens on the hosted page. The result is what Didit recorded when the person came back: not_required, approved, pending, review, declined or expired.

Errors

Every call throws DiditAuthError with a code. The code is the Didit API’s own (invalid_grant, method_unavailable, reauthentication_required) or one of cancelled, invalid_state, not_signed_in, step_up_user_mismatch, passkey_cancelled, passkey_unavailable, browser_unavailable, storage_unavailable, invalid_publishable_key, invalid_redirect_uri, network_error, rate_limited (with retryAfter) and server_error. A sign-out without network still signs the person out on the device.

Connect verification and monitoring

Your backend derives vendor_data from the verified token. It creates verification sessions or mints scoped monitoring tokens for that person, and returns only the session credential or scoped token to your app. The API key stays on the server. Use the iOS verification SDK for identity verification, and follow SDK transaction submission for monitoring. Treat sign-in, verification and transaction decisions separately.

Test it

Test a cold start, background and foreground transitions, closing the browser, token expiry, MFA, sign-out and signing in as another person, on a device.
Last modified on November 21, 2026