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
handleOAuthalternative
Prerequisites
Prerequisites
To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration. 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:Authenticate with a Single Call (Recommended)
CallauthenticateWithOAuth(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
WebAuthenticationSessionsheet. 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 theWebAuthenticationSessionsheet, then a new user creates a passkey and a returning user signs in with theirs.
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. Calllogout()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 throwsParaError.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
handleOAuthflow and throwsParaTwoFactorRequiredErrorfor an account that must complete login 2FA. See .
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.
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
WebAuthenticationSessionyou 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
authenticateWithOAuthfor social login. It runs the provider sign-in, credential setup, and wallet creation, and returns anAuthenticationResult - It works on both Para sign-in experiences, so you don’t need to detect which one runs
handleOAuthremains 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:- alongside social login
- for returning users
- such as MetaMask