> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getpara.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Social Login

> Instructions for implementing social login with the ParaSwift SDK.

export const DemoCallout = ({variant = "card", title = "Interactive Demo", description = "Try the live demo to explore authentication flows and customize your modal before integrating."}) => {
  if (variant === "subtle") {
    return <div className="not-prose my-4 px-4 py-3 rounded-xl border border-orange-200 bg-orange-50/50">
        <div className="flex items-center justify-between gap-4">
          <p className="text-sm text-gray-700 m-0">
            {description}
          </p>
          <a href="https://demo.getpara.com/" target="_blank" rel="noopener noreferrer" className="not-prose flex-shrink-0 inline-flex items-center gap-2 px-3 py-1.5 text-xs font-semibold text-orange-600 bg-white border border-orange-200 rounded-lg hover:bg-orange-50 transition-colors no-underline">
            Try Demo
            <svg width="12" height="12" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
              <path d="M40 472L472 40M472 40H83.2M472 40V428.8" stroke="currentColor" strokeWidth="66.6667" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
          </a>
        </div>
      </div>;
  }
  return <a href="https://demo.getpara.com/" target="_blank" rel="noopener noreferrer" className="not-prose block my-4 p-5 rounded-xl bg-gradient-to-r from-orange-600 via-pink-600 to-purple-600 hover:opacity-95 transition-opacity no-underline">
      <div className="flex items-center justify-between gap-4">
        <div>
          <h3 className="text-base font-semibold text-white m-0">{title}</h3>
          <p className="text-xs text-white/80 mt-1 m-0">{description}</p>
        </div>
        <div className="flex-shrink-0 w-8 h-8 rounded-full bg-white/20 flex items-center justify-center">
          <svg width="14" height="14" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
            <path d="M40 472L472 40M472 40H83.2M472 40V428.8" stroke="white" strokeWidth="66.6667" strokeLinecap="round" strokeLinejoin="round" />
          </svg>
        </div>
      </div>
    </a>;
};

export const Link = ({href, label, newTab = false}) => {
  const [isHovered, setIsHovered] = useState(false);
  return <a href={href} target={newTab ? '_blank' : '_self'} rel={newTab ? 'noopener noreferrer' : undefined} className="not-prose inline-block relative text-black font-semibold cursor-pointer border-b-0 no-underline" onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
      {label}
      <span className={`absolute left-0 bottom-0 w-full rounded-sm bg-gradient-to-r from-orange-600 to-purple-600 transition-all duration-300 ${isHovered ? 'h-0.5' : 'h-px'}`} />
    </a>;
};

## Overview

Social login (OAuth) is integrated directly into Para's unified authentication experience. This guide covers how to implement social login alongside email and phone authentication in a single, streamlined interface. Para supports Google, Apple, and Discord as OAuth providers.

<Info>
  Have your own OpenID Connect provider? Once you [set up Custom OIDC](/v3/general/developer-portal-custom-oidc), use `CUSTOM_OIDC` as the OAuth method — it works like any other provider.
</Info>

## Prerequisites

## Prerequisites

To use Para, you need an API key. This key authenticates your requests to Para services and is essential for
integration.

<Warning>
  Don't have an API key yet? Request access to the <Link label="Developer Portal" href="https://developer.getpara.com" /> to create API keys, manage billing, teams, and more.
</Warning>

<DemoCallout variant="subtle" />

You must have the ParaSwift SDK installed and configured in your project. If you haven't done this yet, please refer to our <Link label="Quick Start Guide" href="/v3/swift/setup" />.

## Unified Authentication Approach

Para's recommended approach is to integrate social login directly into your main authentication view alongside email and phone options. This provides users with all authentication methods in one place.

### Environment Setup

Ensure your authentication view can access the system authentication helpers and register the default web session once:

```swift theme={null}
@Environment(\.webAuthenticationSession) private var webAuthenticationSession
@Environment(\.authorizationController) private var authorizationController

var body: some View {
    VStack { /* auth UI */ }
    .task {
        paraManager.setDefaultWebAuthenticationSession(webAuthenticationSession)
    }
}
```

## Implementing Social Login

### Integration with Unified Auth View

Social login should be integrated alongside email and phone authentication in your main authentication view. Here's a basic example:

```swift theme={null}
import SwiftUI
import ParaSwift
import AuthenticationServices

struct AuthView: View {
    @EnvironmentObject var paraManager: ParaManager

    @Environment(\.webAuthenticationSession) private var webAuthenticationSession
    @Environment(\.authorizationController) private var authorizationController

    @State private var emailOrPhone = ""

    var body: some View {
        VStack(spacing: 20) {
            // Email/Phone input
            TextField("Email or phone number", text: $emailOrPhone)
                .textFieldStyle(RoundedBorderTextFieldStyle())

            Button("Continue") {
                handleEmailPhoneAuth()
            }
            .buttonStyle(.borderedProminent)

            // Divider
            Text("or")
                .foregroundColor(.gray)

            // Social login buttons
            Button("Continue with Google") {
                handleSocialLogin(.google)
            }

            Button("Continue with Apple") {
                handleSocialLogin(.apple)
            }

            Button("Continue with Discord") {
                handleSocialLogin(.discord)
            }
        }
        .padding()
        .task {
            paraManager.setDefaultWebAuthenticationSession(webAuthenticationSession)
        }
    }
}
```

### Handling Social Login

Implement the social login handler that manages the OAuth flow:

```swift theme={null}
private func handleSocialLogin(_ provider: OAuthProvider) {
    Task {
        do {
            try await paraManager.handleOAuth(
                provider: provider,
                authorizationController: authorizationController
            )

            // OAuth flow completed successfully
            // User is now logged in and wallets are available
            print("User authenticated successfully")
            // Navigate to authenticated area of your app
        } catch {
            // Handle OAuth error
            print("OAuth error: \(error.localizedDescription)")
        }
    }
}
```

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
* Uses the default `WebAuthenticationSession` you registered; pass a custom one only if you need to override it for a specific call.

### Creating Social Login Buttons

Create buttons for each OAuth provider:

```swift theme={null}
// Google Login
Button("Continue with Google") {
    handleSocialLogin(.google)
}

// Apple Login
Button("Continue with Apple") {
    handleSocialLogin(.apple)
}

// Discord Login
Button("Continue with Discord") {
    handleSocialLogin(.discord)
}
```

## Available OAuth Providers

The ParaSwift SDK supports the following OAuth providers:

* Google (`.google`)
* Apple (`.apple`)
* Discord (`.discord`)

## Key Points

* Social login is handled through the `handleOAuth` method
* The method manages the complete OAuth flow including user authentication, Para account creation/lookup, and passkey setup for new users
* For existing users, it logs them in directly
* 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. <Link label="Set up email verification" href="/v3/swift/setup" /> for new users
2. <Link label="Implement secure storage" href="/v3/swift/setup" /> for session management
3. <Link label="Add biometric authentication" href="/v3/swift/setup" /> as an additional security layer
