benxu.AppPlatform.Supabase.Auth 3.2.8

dotnet add package benxu.AppPlatform.Supabase.Auth --version 3.2.8
                    
NuGet\Install-Package benxu.AppPlatform.Supabase.Auth -Version 3.2.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="benxu.AppPlatform.Supabase.Auth" Version="3.2.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="benxu.AppPlatform.Supabase.Auth" Version="3.2.8" />
                    
Directory.Packages.props
<PackageReference Include="benxu.AppPlatform.Supabase.Auth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add benxu.AppPlatform.Supabase.Auth --version 3.2.8
                    
#r "nuget: benxu.AppPlatform.Supabase.Auth, 3.2.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package benxu.AppPlatform.Supabase.Auth@3.2.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=benxu.AppPlatform.Supabase.Auth&version=3.2.8
                    
Install as a Cake Addin
#tool nuget:?package=benxu.AppPlatform.Supabase.Auth&version=3.2.8
                    
Install as a Cake Tool

benxu.AppPlatform.Supabase.Auth

Supabase Authentication 實作套件,提供 Email/PasswordGoogle OAuthApple OAuth 與 Access Token 自動刷新能力,適用於 .NET MAUI App。

功能特色

  • 使用 Supabase 套件建立原生 MAUI 可用的認證流程。
  • 實作既有平台抽象 IAuthService,可直接接上目前 App Platform 的認證流程。
  • 支援 Google / Apple OAuth,採用 PKCE + WebAuthenticator + deep link callback
  • 內建 Token 自動刷新,並將登入狀態同步到 IAppStateManager
  • 支援 App 重啟後從既有 AuthState 還原 Session。

安裝

dotnet add package benxu.AppPlatform.Supabase.Auth

前置設定

  1. 在 Supabase Dashboard 設定 Auth > URL Configuration,加入 App 的 deep link callback。
  2. 在 Google / Apple Provider 設定中,將對應 callback URL 加入允許清單。
  3. 在 MAUI App 平台專案設定 deep link / callback scheme,讓 WebAuthenticator 能回到 App。

使用方式

1. 註冊服務

using benxu.AppPlatform.Supabase.Auth.Extensions;
using benxu.AppPlatform.Supabase.Auth.Options;

builder.Services.AddSupabaseAuth(new SupabaseAuthOptions
{
    ProjectUrl = "https://your-project.supabase.co",
    AnonKey = "YOUR_SUPABASE_ANON_KEY",
    GoogleRedirectUri = "com.yourcompany.yourapp://auth/google",
    AppleRedirectUri = "com.yourcompany.yourapp://auth/apple",
    EnableAutoTokenRefresh = true
});

2. 使用認證服務

@inject IAuthService AuthService

@code {
    /// <summary>
    /// 觸發 Google 登入
    /// </summary>
    /// <returns>非同步工作</returns>
    private async Task LoginWithGoogleAsync()
    {
        var result = await AuthService.SignInWithGoogleAsync();

        if (result.IsSuccess)
        {
            Console.WriteLine(result.Data.User.Email);
        }
    }
}

注意事項

  • Supabase 的 C# Client 由社群維護,不是官方一方套件;本套件目前使用 Supabase 1.1.1
  • SignUpWithEmailAsync() 在 Supabase 專案啟用 Confirm email 時,會出現「建立成功但需先驗證 Email」的情況;此時本套件會回傳可識別的失敗代碼 AUTH_EMAIL_CONFIRMATION_REQUIRED
  • Google / Apple OAuth 目前依賴 WebAuthenticator 與正確的 deep link callback 設定。

依賴項目

  • Supabase (1.1.1)
  • benxu.AppPlatform.Core
  • Microsoft.Maui.Controls

授權

MIT License

Product Compatible and additional computed target framework versions.
.NET net10.0-android36.0 is compatible.  net10.0-ios26.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on benxu.AppPlatform.Supabase.Auth:

Package Downloads
benxu.AppPlatform.MAUI.Bootstrap

Bootstrap package for benxu App Platform. Provides fluent API for one-line service registration and lifecycle management.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.2.8 47 7/7/2026