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.

.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.

Short Coding Tutorials for .NET & NodeJS