FirebaseAuth.NET 1.4.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package FirebaseAuth.NET --version 1.4.4
                    
NuGet\Install-Package FirebaseAuth.NET -Version 1.4.4
                    
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="FirebaseAuth.NET" Version="1.4.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FirebaseAuth.NET" Version="1.4.4" />
                    
Directory.Packages.props
<PackageReference Include="FirebaseAuth.NET" />
                    
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 FirebaseAuth.NET --version 1.4.4
                    
#r "nuget: FirebaseAuth.NET, 1.4.4"
                    
#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 FirebaseAuth.NET@1.4.4
                    
#: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=FirebaseAuth.NET&version=1.4.4
                    
Install as a Cake Addin
#tool nuget:?package=FirebaseAuth.NET&version=1.4.4
                    
Install as a Cake Tool

πŸ” FirebaseAuth.NET

A simple, cross-platform Firebase Authentication library for .NET 9 apps (MAUI, Blazor, Console, etc.)
Supports Email + Password login, registration, password reset, token persistence with custom secure storage abstraction, account deletion (unregister), password change, and email change.


πŸ“¦ Install from NuGet

dotnet add package FirebaseAuth.NET

NuGet: https://www.nuget.org/packages/FirebaseAuth.NET


🧱 Features

βœ… Email + Password Authentication
βœ… Password Reset
βœ… Change Password
βœ… Change Email
βœ… Auto Token Refresh
βœ… Reusable SecureStorage abstraction
βœ… Works in .NET 9 MAUI, Blazor, WPF, API, or Console
βœ… Account deletion (Unregister)
βœ… Optional typed errors via FirebaseAuthException and AuthErrorReason


βš™οΈ Setup in a MAUI App

1️⃣ Create a Secure Storage Adapter

Storage/MauiSecureStorage.cs

using FirebaseAuth.NET.Storage;

namespace MyApp.Storage;

public class MauiSecureStorage : ISecureStorage
{
    public Task SetAsync(string key, string value) => SecureStorage.Default.SetAsync(key, value);
    public Task<string?> GetAsync(string key) => SecureStorage.Default.GetAsync(key);
    public void Remove(string key) => SecureStorage.Default.Remove(key);
}

2️⃣ Register Dependencies

MauiProgram.cs

using FirebaseAuth.NET.Services;
using FirebaseAuth.NET.Storage;
using MyApp.Storage;

public static class MauiProgram
{
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();

        // Register Firebase Auth
        builder.Services.AddSingleton<ISecureStorage, MauiSecureStorage>();
        builder.Services.AddSingleton<IFirebaseAuthService>(sp =>
        {
            var logger = sp.GetRequiredService<ILogger<FirebaseAuthService>>();
            var storage = sp.GetRequiredService<ISecureStorage>();
            var http = new HttpClient();
            var apiKey = "YOUR_FIREBASE_API_KEY"; // from Firebase Console
            var options = new FirebaseAuthOptions
            {
                // Optional: throw typed errors that you can handle in UI
                ThrowOnError = true,
                // Optional: disable registration endpoints
                // AllowRegistration = false
            };
            return new FirebaseAuthService(http, logger, storage, apiKey, options);
        });

        return builder.Build();
    }
}

3️⃣ Use It Anywhere

using FirebaseAuth.NET.Services;

public partial class LoginPage : ContentPage
{
    private readonly IFirebaseAuthService _auth;

    public LoginPage(IFirebaseAuthService auth)
    {
        InitializeComponent();
        _auth = auth;
    }

    private async void OnLoginClicked(object sender, EventArgs e)
    {
        try
        {
            var user = await _auth.LoginAsync("test@example.com", "password123");
            if (user != null)
                await DisplayAlert("Welcome", $"Logged in as {user.Email}", "OK");
            else
                await DisplayAlert("Error", "Login failed.", "OK");
        }
        catch (FirebaseAuthException ex)
        {
            // Handle typed errors when ThrowOnError = true
            switch (ex.Reason)
            {
                case AuthErrorReason.InvalidEmailAddress:
                    await DisplayAlert("Error", "Invalid email address.", "OK");
                    break;
                case AuthErrorReason.InvalidPassword:
                    await DisplayAlert("Error", "Invalid password.", "OK");
                    break;
                default:
                    await DisplayAlert("Error", ex.Message, "OK");
                    break;
            }
        }
    }

    private async void OnForgotPasswordClicked(object sender, EventArgs e)
    {
        var success = await _auth.SendPasswordResetEmailAsync("test@example.com");
        await DisplayAlert("Reset Password", success ? "Email sent." : "Failed to send.", "OK");
    }

    private async void OnChangePasswordClicked(object sender, EventArgs e)
    {
        var success = await _auth.ChangePasswordAsync("NewStrongPassword!234");
        await DisplayAlert("Change Password", success ? "Password updated." : "Failed to update password.", "OK");
    }

    private async void OnChangeEmailClicked(object sender, EventArgs e)
    {
        var success = await _auth.ChangeEmailAsync("new.email@example.com");
        await DisplayAlert("Change Email", success ? "Email updated." : "Failed to update email.", "OK");
    }

    private async void OnUnregisterClicked(object sender, EventArgs e)
    {
        var success = await _auth.UnregisterAsync();
        await DisplayAlert("Unregister", success ? "Account deleted." : "Failed to delete account.", "OK");
    }
}

Notes

  • Changing email requires the user to be signed in and often a recent login.
  • Depending on your Firebase settings, email change may require email verification. Handle EMAIL_EXISTS, INVALID_EMAIL, and CREDENTIAL_TOO_OLD_LOGIN_AGAIN errors for best UX.

4️⃣ Logout Example

_auth.Logout();

🧩 Advanced

  • Implement your own ISecureStorage (e.g., file, key vault, or mock for testing).
  • Control registration availability using options (default allows registration):
var options = new FirebaseAuthOptions { AllowRegistration = false };
var auth = new FirebaseAuthService(http, logger, storage, "YOUR_FIREBASE_API_KEY", options);
  • Enable typed errors in UI-friendly way:
var options = new FirebaseAuthOptions { ThrowOnError = true };

πŸ§ͺ Example Usage (Console App)

var http = new HttpClient();
var storage = new FileSecureStorage(); // your own ISecureStorage implementation
var logger = LoggerFactory.Create(b => b.AddConsole()).CreateLogger<FirebaseAuthService>();

var options = new FirebaseAuthOptions { ThrowOnError = true };
var auth = new FirebaseAuthService(http, logger, storage, "YOUR_FIREBASE_API_KEY", options);

try
{
    var user = await auth.RegisterAsync("user@example.com", "password123");
    Console.WriteLine($"Registered user: {user?.Email}");
}
catch (FirebaseAuthException ex)
{
    if (ex.Reason == AuthErrorReason.EmailExists)
        Console.WriteLine("Email already exists");
    else
        Console.WriteLine($"Registration failed: {ex.Message}");
}

var changedPassword = await auth.ChangePasswordAsync("newP@ssw0rd!");
Console.WriteLine(changedPassword ? "Password changed" : "Password change failed");

var changedEmail = await auth.ChangeEmailAsync("new@email.com");
Console.WriteLine(changedEmail ? "Email changed" : "Email change failed");

var deleted = await auth.UnregisterAsync();
Console.WriteLine(deleted ? "Account deleted" : "Delete failed");

🌐 Cross-platform notes

  • Uses ILogger for retry logging instead of Console, suitable for MAUI, Blazor, ASP.NET, WPF, and Console.
  • Storage is abstracted behind ISecureStorage; provide a platform-appropriate implementation.
  • Works with HttpClient everywhere. In Blazor WebAssembly, ensure CORS is allowed for Google Identity Toolkit endpoints (default is fine), and construct HttpClient from DI.

πŸ“˜ API Docs

  • Methods include XML summaries for IntelliSense and documentation tooling.
  • Typed errors: FirebaseAuthException with AuthErrorReason for granular error handling when ThrowOnError is enabled.

πŸ§‘β€πŸ’» Author

Imre SzΓΌcs
Licensed under MIT


🌟 Contribute

Pull requests and improvements are welcome!
If you find a bug, please open an issue: https://github.com/szucsim/FirebaseAuth.NET/issues

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.8.0 104 5/21/2026
1.7.1 516 11/20/2025
1.7.0 426 11/18/2025
1.6.0 249 11/16/2025
1.5.0 170 11/15/2025
1.4.4 302 11/12/2025
1.4.3 236 11/10/2025
1.4.0 194 10/25/2025
1.3.2 133 10/24/2025
1.3.1 137 10/24/2025
1.3.0 130 10/24/2025
1.2.0 139 10/24/2025
1.1.0 200 10/23/2025
1.0.1 204 10/21/2025
1.0.0 186 10/21/2025

1.4.4: Fix to throw correct exceptions.
     1.4.3: Internal validation improvements for error mapping.
     1.4.2: Improved parsing of nested Firebase error payloads (e.g. "INVALID_ARGUMENT: INVALID_LOGIN_CREDENTIALS") so LoginAsync now throws AuthErrorReason.InvalidLoginCredentials instead of Unknown.
     1.4.1: Map and throw INVALID_LOGIN_CREDENTIALS during LoginAsync when ThrowOnError is enabled.
     1.4.0: Added ChangeEmailAsync to allow changing the signed-in user's email; updated README; includes XML documentation.