Passer au contenu

Supabase Integration Introduction

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.

  • 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

Before you begin, make sure you have:

  1. A Supabase Project

  2. Supabase JS SDK

    • Installer Supabase in your project:
      Terminal window
      npm install @supabase/supabase-js
  3. A Capacitor Project

    • An existing Capacitor Application
    • Capacitor Social Connexion plugin installed:
      Terminal window
      npm install @capgo/capacitor-social-login
      npx cap sync
  4. Platform-Specific Google Configuration

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)

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 nonceDigest to Google Sign-In
  • Pass rawNonce to Supabase (Supabase hashes it internally for comparison)

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)
  • 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

Continue with the Configuration guides: