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.
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.
Ensure your authentication view has access to the required environment values:
Copy
Ask AI
@Environment(\.webAuthenticationSession) private var webAuthenticationSession@Environment(\.authorizationController) private var authorizationController
Implement the social login handler that manages the OAuth flow:
Copy
Ask AI
private func handleSocialLogin(_ provider: OAuthProvider) { Task { do { let result = await paraManager.handleOAuth( provider: provider, webAuthenticationSession: webAuthenticationSession, authorizationController: authorizationController ) if result.success { // OAuth flow completed successfully // User is now logged in and wallets are available print("User authenticated successfully") // Navigate to authenticated area of your app } else { // Handle OAuth error print("OAuth error: \(result.errorMessage ?? "Unknown error")") } } catch { // Handle error print("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 a success/failure result with any error message
// Google LoginButton("Continue with Google") { handleSocialLogin(.google)}// Apple Login Button("Continue with Apple") { handleSocialLogin(.apple)}// Discord LoginButton("Continue with Discord") { handleSocialLogin(.discord)}