Using Firebase Authentication JWT Tokens in ASP.NET Core (.NET 5)

Enabling your secured AspNetCore Web API to accept Firebase tokens is quite simple actually. All you have to do is register the JWTBearer and add the firebase issuer information, detailed steps are below.

This tutorial assumes that you already have an AspNetCore API and a corresponding Frontend that uses Firebase for authentication.

1. Install the JWT Nuget package

2. Register your Authentication Service in Startup.cs

.AddJwtBearer(options =>
options.Authority = "";
options.TokenValidationParameters = new TokenValidationParameters
ValidateIssuer = true,
ValidIssuer = "",
ValidateAudience = true,
ValidAudience = "FIREBASE-APP-ID",
ValidateLifetime = true

Enable Authorization & Authentication in Startup.cs


3 Add the [Authorize] Annotation to your endpoints.

The above example also shows you how you can get the user UUID from the token by using token Claims.

And that’s all there is to it. You’ve now successfully secured your AspNetCore Web API with Firebase.

Thanks for reading.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store