Skip to main content

Overview

authenticateWithOAuth signs a user up or in with Google, Apple, or Discord and returns once they have an active session. Para runs the provider sign-in, any credential setup, and wallet creation. Add social login alongside email and phone so users see every sign-in option in one place. This guide covers:
  • The recommended single-call flow with authenticateWithOAuth
  • A SwiftUI view with email, phone, and social sign-in
  • The manual handleOAuth alternative

Prerequisites

Prerequisites

To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration.
Don’t have an API key yet? Request access to the to create API keys, manage billing, teams, and more.
You must have the ParaSwift SDK installed and configured in your project. If you haven’t done this yet, please refer to our . Social login relies on the URL scheme (appScheme) and Associated Domains (passkeys) you configure there.

Environment Setup

Ensure your authentication view can access the system authentication helpers and register the default web session once:
Call authenticateWithOAuth(provider:authorizationController:webAuthenticationSession:) with the provider the user picked. It works for both new and returning users and returns the same AuthenticationResult as authenticateWithEmailOrPhone:

What the user sees

Para decides which sign-in experience runs for your app. You don’t configure or detect it, so build for both:
  • Para’s updated authentication flow. The user signs in with the provider on a Para-hosted page shown in the WebAuthenticationSession sheet. A new user then creates their first credential. When your app offers passkeys and the device can create one, iOS shows the native passkey prompt. Otherwise the user sets a password, or a PIN when your app offers only PINs, on a Para-hosted page. A device can’t create a passkey without a device passcode; if your app offers no password or PIN, the SDK still tries the native passkey prompt. A returning user whose account is protected by a passkey is returned to your app and signs in with the native passkey prompt. That passkey must belong to the account the provider signed in. A returning password user unlocks on a Para-hosted page.
  • Provider sign-in, then passkey in your app. The SDK runs the same flow as handleOAuth: the user signs in with the provider in the WebAuthenticationSession sheet, then a new user creates a passkey and a returning user signs in with theirs.
In both cases the call returns once the user is signed in, and new users’ wallets are created before it returns.
A WebAuthenticationSession is required. Register one with setDefaultWebAuthenticationSession(_:) as shown above, or pass webAuthenticationSession: to the call. Without one, the call throws before opening the provider.

Example: SwiftUI with email, phone, and social sign-in

AuthView.swift

Handle errors

authenticateWithOAuth throws when sign-in can’t finish. Common cases:
  • A user is already signed in. On Para’s updated authentication flow the call throws ParaError.error("A user is already signed in. Call logout() before signing in again.") instead of starting a new sign-in. Call logout() first.
  • The user cancels. Closing the provider or Para-hosted sheet, including the credential setup page, or the passkey prompt throws and cancels sign-in. On Para’s updated authentication flow, closing a Para-hosted sheet throws ParaError.error("Authentication cancelled").
  • The wrong passkey. When a returning user is asked for their passkey and picks one that belongs to a different account, the call throws ParaError.error("That passkey belongs to a different account. Choose the passkey for this account.") and that sign-in is discarded. The user can try again with the right passkey. If the Para-hosted page hands back without naming the account, the call throws ParaError.error("The sign-in page did not say which account to sign in to.").
  • No WebAuthenticationSession. The call throws before opening the provider.
  • Two-factor authentication is required. On Para’s updated authentication flow the user completes login 2FA on the Para-hosted page. When the updated flow isn’t running for your app, the call runs the handleOAuth flow and throws ParaTwoFactorRequiredError for an account that must complete login 2FA. See .
After a failure you can call authenticateWithOAuth again right away.

Manual Alternative: handleOAuth

handleOAuth(provider:webAuthenticationSession:authorizationController:) remains available. It always runs the provider sign-in followed by a passkey in your app, and doesn’t use Para’s updated authentication flow. It can’t host login 2FA, so it cancels the sign-in and throws ParaTwoFactorRequiredError when the account must complete it. New integrations should prefer authenticateWithOAuth.
The handleOAuth method:
  • Authenticates the user with the OAuth provider
  • Checks if a Para account exists for the user
  • For new users: creates a Para account and sets up a passkey automatically
  • For existing users: logs them in directly
  • Returns nothing on success, throws errors on failure (including ParaTwoFactorRequiredError)
  • Uses the default WebAuthenticationSession you registered; pass a custom one only if you need to override it for a specific call.

Available OAuth Providers

The ParaSwift SDK supports the following OAuth providers:
  • Google (.google)
  • Apple (.apple)
  • Discord (.discord)

Key Points

  • Use authenticateWithOAuth for social login. It runs the provider sign-in, credential setup, and wallet creation, and returns an AuthenticationResult
  • It works on both Para sign-in experiences, so you don’t need to detect which one runs
  • handleOAuth remains available for the provider-then-passkey flow
  • The SDK supports Google, Apple, and Discord as OAuth providers
  • Social login should be integrated with email/phone authentication for a unified experience

Next Steps

After implementing social login, you might want to:
  1. alongside social login
  2. for returning users
  3. such as MetaMask