FirebaseAuth.NET
1.4.4
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
<PackageReference Include="FirebaseAuth.NET" Version="1.4.4" />
<PackageVersion Include="FirebaseAuth.NET" Version="1.4.4" />
<PackageReference Include="FirebaseAuth.NET" />
paket add FirebaseAuth.NET --version 1.4.4
#r "nuget: FirebaseAuth.NET, 1.4.4"
#:package FirebaseAuth.NET@1.4.4
#addin nuget:?package=FirebaseAuth.NET&version=1.4.4
#tool nuget:?package=FirebaseAuth.NET&version=1.4.4
π 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, andCREDENTIAL_TOO_OLD_LOGIN_AGAINerrors 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
ILoggerfor retry logging instead ofConsole, suitable for MAUI, Blazor, ASP.NET, WPF, and Console. - Storage is abstracted behind
ISecureStorage; provide a platform-appropriate implementation. - Works with
HttpClienteverywhere. In Blazor WebAssembly, ensure CORS is allowed for Google Identity Toolkit endpoints (default is fine), and constructHttpClientfrom DI.
π API Docs
- Methods include XML summaries for IntelliSense and documentation tooling.
- Typed errors:
FirebaseAuthExceptionwithAuthErrorReasonfor granular error handling whenThrowOnErroris 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 | Versions 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. |
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
- Polly (>= 8.6.4)
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.