Supabase Integration Introduction
Aperçu
Section titled “Aperçu”This Tutoriel will Guide you through setting up Supabase Authentication with the Capacitor Social Connexion plugin. This integration allows you to use Natif social Connexion providers (Google, Apple, Facebook, Twitter) on mobile platforms while leveraging Supabase Auth for backend authentication and PostgreSQL for data storage.
What You’ll Learn
Section titled “What You’ll Learn”- How to configure Supabase Authentication
- How to integrate Capacitor Social Connexion plugin with Supabase Auth
- Platform-specific Configuration for Android, iOS, and Web
- How to handle nonces securely for Supabase
What You’ll Need
Section titled “What You’ll Need”Before you begin, make sure you have:
-
A Supabase Project
- Créer a project at Supabase Tableau de bord
- Activer Google OAuth provider
- Get your Supabase project URL and anon key
-
Supabase JS SDK
- Installer Supabase in your project:
Terminal window npm install @supabase/supabase-js
- Installer Supabase in your project:
-
A Capacitor Project
- An existing Capacitor Application
- Capacitor Social Connexion plugin installed:
Terminal window npm install @capgo/capacitor-social-loginnpx cap sync
-
Platform-Specific Google Configuration
- Terminé the Google Sign-In Configuration for your target platforms:
Exemple Application
Section titled “Exemple Application”A Terminé working Exemple is Disponible in the repository:
Code Repository: You can find the code repository here
The Exemple Application demonstrates:
- Email/password authentication with Supabase
- Google Sign-In integration (Android, iOS, and Web)
- A simple key-value store using Supabase PostgreSQL tables
- Utilisateur-specific data storage with Row Level Sécurité (RLS)
Key Implementation Details
Section titled “Key Implementation Details”Nonce Handling
Section titled “Nonce Handling”Supabase requires special nonce handling for Sécurité. The implementation follows the React Natif Google Sign In Documentation:
- Generate a
rawNonce(URL-safe random string) - Hash it with SHA-256 to get
nonceDigest - Pass
nonceDigestto Google Sign-In - Pass
rawNonceto Supabase (Supabase hashes it internally for comparison)
JWT Validation
Section titled “JWT Validation”The Exemple implementation includes JWT validation to ensure:
- The token audience matches your configured Google Client IDs
- The nonce matches the expected digest
- Automatic retry on validation failure (especially Important for iOS)
Platform-Specific Considerations
Section titled “Platform-Specific Considerations”- iOS: Token caching can cause nonce issues - the implementation handles this automatically
- Web: Must call
isLoggedIn()on mount to handle OAuth redirects - Android: Standard implementation with SHA-1 fingerprint Configuration
Suivant Steps
Section titled “Suivant Steps”Continue with the Configuration guides:
- Supabase Google Connexion - General Configuration - Aperçu and prerequisites
- Android Configuration - Android-specific Configuration
- iOS Configuration - iOS-specific Configuration
- Web Configuration - Web-specific Configuration
Apple Sign-In
Section titled “Apple Sign-In”- Supabase Apple Connexion - General Configuration - Aperçu and prerequisites
- iOS Configuration - iOS-specific Configuration
- Android Configuration - Android-specific Configuration