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
There is a newer prerelease version of this package available. See the version list below for details. Showing the top…
2. Register your Authentication Service in Startup.cs
options.Authority = "https://securetoken.google.com/FIREBASE-APP-ID";
options.TokenValidationParameters = new TokenValidationParameters
ValidateIssuer = true,
ValidIssuer = "https://securetoken.google.com/FIREBASE-APP-ID",
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.