Hosted Authentication

Register or log in a user using a Passage Hosted Login page

Using Hosted Authentication is the fastest and easiest way to get your iOS app setup with Passage and passkeys. When you create your Passage App in the Passage Console, you'll need to select "Hosted Login" from the app creation options.

See Add Passage for how to configure your app.

Authenticate user with Hosted Auth

To register or log in your user, use passage.hostedAuth():

do {
  try await passage.hostedAuth()
  // passage.getCurrentUser should now return the authenticated user
  guard let user = try await passage.getCurrentUser() else { return }
    // Do authenticated stuff
} catch HostedAuthorizationError.canceled {
  // User canceled authentication flow.
} catch {
  // An unexpected error occurred.
}

Log out user

The secure hosted web view will keep your auth session until it expires. To clear the web view auth session and remove user's tokens from device, use passage.hostedLogout:

do {
  try await passage.hostedLogout()
} catch HostedAuthorizationError.canceled {
  // User canceled logout.
} catch {
  // An unexpected error occurred.
}

Last updated