Firebase Authentication C# Library
Tomáš Bezouška
509

I’ve implemented Firebase authentication into my ASP.NET MVC application. I set the Firebase authentication to accept only Email/Password auth on console.firebase.google.com. Of course add some packages to the VisualStudio project from NuGet: Firebase, Firebase.Auth, Firebase.Storage (if you need this also). The author of these packages is Step Up Labs, of course.

In AccountController.cs you have to modify only the

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

line with the custom one:

var result = await ConnectGoogleServiceController.AccessFirebase(model);

The create your on controller named: ConnectGoogleServiceController:

public class ConnectGoogleServiceController : Controller
{
public static async Task<SignInStatus> AccessFirebase(LoginViewModel model)
{
string webApiKey=”<YOUR WEB API KEY FOUND ON console.firebase.google.com UNDER YOU PROJECT SETTINGS>”;
FirebaseAuthProvider authProvider=new FirebaseAuthProvider(new FirebaseConfig(webApiKey));
try
{
FirebaseAuthLink auth = await authProvider.SignInWithEmailAndPasswordAsync(model.Email, model.Password);
}
catch (FirebaseAuthException)
{
return SignInStatus.Failure;
}
return SignInStatus.Success;
}
}