百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

firebase-authentication-dotnet

> 数据库
开源

用于 Firebase 身份验证的 C# 库

397 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 Firebase 身份验证的 C# 库

FirebaseAuthentication.net

FirebaseAuthentication.net is an unofficial C# implementation of Firebase Authentication and FirebaseUI.

The libraries provide a drop-in auth solution that handles the flows for signing in users with email addresses and passwords, Identity Provider Sign In including Google, Facebook, GitHub, Twitter, Apple, Microsoft and anonymous sign-in.

The solution consists of 5 libraries - a base one and 4 platform specific ones:

  • FirebaseAuthentication.net targets .NET Standard 2.0
  • FirebaseAuthentication.WPF targets WPF on .NET 6
  • FirebaseAuthentication.UWP targets UWP with min version 19041
  • FirebaseAuthentication.WinUI3 targets WinUI3
  • FirebaseAuthentication.Maui targets Maui (TODO)

Installation

Either via Visual Studio Nuget package manager, or from command line:

powershell
# base package
dotnet add package FirebaseAuthentication.net

# Platform specific FirebaseUI (has dependency on base package)
dotnet add package FirebaseAuthentication.WPF
dotnet add package FirebaseAuthentication.UWP
dotnet add package FirebaseAuthentication.WinUI3
dotnet add package FirebaseAuthentication.Maui

Use the --version option to specify a preview version to install.

Daily preview builds are also available on feedz.io. Just add the following Package Source to your Visual Studio:

https://f.feedz.io/step-up-labs/firebase/nuget/index.json

Usage

In general the terminology and API naming conventions try to follow the official JavaScript implementation, adjusting it to fit the .NET conventions. E.g. signInWithCredential is called SignInWithCredentialAsync because it is meant to be awaited, but otherwise the terminology should be mostly the same.

Samples

There are currently 3 sample projects in the samples folder:

  • .NET Core Console application (uses only the base library, no UI)
  • WPF sample with UI
  • UWP sample with UI
  • WinUI3 sample with UI

Feel free to clone the repo and check them out, just don't forget to add your custom API keys and other setup (typically in Program.cs or App.xaml.cs).

Setup

For general Firebase setup, refer to the official documentation which discusses the general concepts and individual providers in detail. You might also want to check out the first two steps in this web documentation. Notice that Firebase doesn't officially support Windows as a platform so you will have to register your application as a web app in Firebase Console.

FirebaseAuthentication.net

The base library gives you the same features as the official Firebase SDK Authentication, that is without any UI. Your entrypoint is the FirebaseAuthClient.

…

Notice the UserRepository. This tells FirebaseAuthClient where to store the user's credentials. By default the libraries use in-memory repository; to preserve user's credentials between application runs, use FileUserRepository (or your custom implementation of IUserRepository).

After you have your client, you can sign-in or sign-up the user with any of the configured providers.

…

As you can see the sign-in methods give you a UserCredential object, which contains an AuthCredential and a User objects. User holds details about a user as well as some useful methods, e.g. GetIdTokenAsync() to get a valid IdToken you can use as an access token to other Firebase API (e.g. Realtime Database).

csharp
// user and auth properties
var user = userCredential.User;
var uid = user.Uid;
var name = user.Info.DisplayName; // more properties are available in user.Info
var refreshToken = user.Credential.RefreshToken; // more properties are available in user.Credential

// user methods
var token = await user.GetIdTokenAsync();
await user.DeleteAsync();
await user.ChangePasswordAsync("new_password");
await user.LinkWithCredentialAsync(authCredential);

To sign out a user simply call

csharp
client.SignOut();

FirebaseUI

The platform specific UI libraries use the FirebaseAuthClient under the hood, but need to be initilized via the static Initialize method of FirebaseUI:

csharp
// Initialize FirebaseUI during your application startup (e.g. App.xaml.cs)
FirebaseUI.Initialize(new FirebaseUIConfig
{
    ApiKey = "",
    AuthDomain = ".firebaseapp.com",
    Providers = new FirebaseAuthProvider[]
    {
        new GoogleProvider().AddScopes("email"),
        new EmailProvider()
        // and others
    },
    PrivacyPolicyUrl = "",
    TermsOfServiceUrl = "",
    IsAnonymousAllowed = true,
    UserRepository = new FileUserRepository("FirebaseSample") // persist data into %AppData%\FirebaseSample
});

Notice the UserRepository. This tells FirebaseUI where to store the user's credentials. By default the libraries use in-memory repository; to preserve user's credentials between application runs, use FileUserRepository (or your custom implementation of IUserRepository).

FirebaseUI comes with FirebaseUIControl you can use in your xaml as follows:

xml

    
        
            
                
                
            
        
    

Toggling the visibility of this UI control is up to you, depending on your business logic. E.g. you could show it as a popup, or a Page inside a Frame etc. You would typically want to toggle the control's visibility in response to the AuthStateChanged event:

…

Issues· 46 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#firebasefirebase-authenticationfirebase-databasefirebase-realtime-database

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库