Skip to main content

Installation

Add InsForge to your Swift Package Manager dependencies:

Enable Logging (Optional)

For debugging, you can configure the SDK log level and destination:
Log Levels: Log Destinations:
Use .info or .error in production to avoid exposing sensitive data in logs.

signUp()

Create a new user account with email and password.

Parameters

  • email (String) - User’s email address
  • password (String) - User’s password
  • name (String, optional) - User’s display name

Returns

SignUpResponse

Example (complete flow with verification)

Email verification

For users who register with email, the InsForge backend provides three options:
  1. No email verification - Users can sign in immediately after registration. SignUpResponse will have hasSession = true.
  2. Link-based verification - Users must open their email and click the verification link before they can sign in.
  3. Code-based verification - The InsForge backend sends a 6-digit verification code to the user’s email. The client app needs to display a verification screen where users can enter the code, then call verifyEmail(email:code:) to complete verification. Only after this can users sign in with email + password.
When requireEmailVerification is true, the response will have:
  • accessToken = nil
  • user = nil
  • needsEmailVerification = true
This indicates that verification via option 2 or 3 is required before the user can sign in.

signIn()

Sign in an existing user with email and password.

Parameters

  • email (String) - User’s email address
  • password (String) - User’s password

Example

Email verification

If the sign in response is:
This indicates that verification via option 2 or 3 (link or code, see signUp()) is required before the user can sign in.

signOut()

Sign out the current user.

Example


getCurrentUser()

Get authenticated user with profile data.

Example


setProfile()

Update current user’s profile.

Example


Password reset

InsForge supports two password reset methods, configured in the backend:
  • Code method: User receives a 6-digit code via email, verifies it to get a reset token, then resets password
  • Link method: User receives a magic link via email containing the reset token, then resets password directly

sendPasswordReset()

Send a password reset email to the user. The email will contain either a 6-digit code or a magic link depending on the backend configuration.

Parameters

  • email (String) - User’s email address

Example


exchangeResetPasswordToken()

Exchange a 6-digit reset code for a reset token. This method is only used with the code-based reset flow.

Parameters

  • email (String) - User’s email address
  • code (String) - 6-digit numeric code received via email

Returns

ResetPasswordTokenResponse

Example


resetPassword()

Reset the user’s password using a reset token.

Parameters

  • otp (String) - Reset token (from exchangeResetPasswordToken() for code flow, or from magic link URL for link flow)
  • newPassword (String) - New password meeting the configured requirements

Example


signInWithOAuthView()

Sign in directly with a specific OAuth provider. This method opens the OAuth provider’s authentication page directly. On iOS 12+ and macOS 10.15+, the SDK uses ASWebAuthenticationSession to present an in-app authentication browser with automatic callback handling.

Supported providers

Parameters

  • provider (OAuthProvider) - The OAuth provider to authenticate with
  • redirectTo (String) - Callback URL where InsForge will redirect after authentication

Returns

Returns AuthResponse containing the authenticated user and session tokens.

Authentication flow

Example

URL scheme configuration

Register a callback URL for your app, pass that exact value to redirectTo, and add the same value to allowedRedirectUrls in Auth Settings. For example, you can use a deep link such as yourapp://auth/callback or a claimed HTTPS callback such as https://app.example.com/auth/callback. Requests fail with HTTP 400 if redirectTo is not allowlisted.

Error handling