Implementing social login with Para in Flutter applications
Para supports social login authentication in Flutter applications, allowing users to sign in using popular providers like Google, Apple, Twitter, Discord, and Farcaster. This guide explains how to implement social login in your Flutter app using Para’s Flutter SDK.
The social login flow in mobile applications requires handling browser sessions and deeplinks to redirect users back to your app after successful authentication. Once the social login flow completes, Para uses the returned identifier to authenticate users through the standard email-based flow, creating or authenticating with a native passkey.
Replace YOUR_APP_SCHEME with your application’s unique URL scheme (e.g., paraflutter). This scheme must be unique to your application and will be used for redirecting back to your app after authentication.
import 'package:para/para.dart';import 'package:para_flutter/client/para.dart';// OAuth connection with Parafinal oAuthResponse = await para.oAuthConnect(provider, "YOUR_APP_SCHEME");// For existing usersif (oAuthResponse.userExists) { // Login with the email from OAuth response final wallet = await para.login(email: oAuthResponse.email);} // For new userselse { // Verify OAuth completion final biometricsId = await para.verifyOAuth(); // Generate passkey await para.generatePasskey(oAuthResponse.email!, biometricsId); // Create wallet final result = await para.createWallet(skipDistribute: false);}
Social login with Para still requires creating a native passkey to secure the user’s wallets. After social authentication completes, Para associates a native passkey with the user’s account. For returning users, the native passkey is used for authentication. The passkey is associated on a per-app basis, making authentication streamlined, and users will only see passkey options they created for your specific app.
You may want to check if a user is already authenticated when your app starts:
Copy
Ask AI
// Check if user is logged infinal isLoggedIn = await para.isFullyLoggedIn();// If logged in, get user walletsif (isLoggedIn) { final wallets = await para.getWallets(); // Process wallets as needed}