1
votes

I am working on mobile app that uses Firebase for authentication but I am unable to verify a Jwt from Firebase on asp net core 2 app, the problem I have is getting the IssuerSigningKey, here is a sample of my code in asp net core start up class. From Firebase Documentation, they say I should obtain the certificate from https://www.googleapis.com/robot/v1/metadata/x509/[email protected]. I cannot proceed from there

 services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
   .AddJwtBearer(options =>
   {
       options.TokenValidationParameters = new TokenValidationParameters
       {
           ValidateIssuer = true,
           ValidateAudience = true,
           ValidateLifetime = true,
           ValidateIssuerSigningKey = true,
           ValidIssuer = Configuration["Jwt:Issuer"],
           ValidAudience = Configuration["Jwt:aud"],
           IssuerSigningKey = 

       };
   });
1

1 Answers

1
votes

I have finally found an answer from this site https://blog.markvincze.com/secure-an-asp-net-core-api-with-firebase/ all I needed to add was options.Authority = Configuration["Jwt:Issuer"]; and removing the issuer signing key

 services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
 .AddJwtBearer(options =>
 {
     options.Authority = Configuration["Jwt:Issuer"];
   options.TokenValidationParameters = new TokenValidationParameters
   {
       ValidateIssuer = true,
       ValidateAudience = true,
       ValidateLifetime = true,
       ValidateIssuerSigningKey = true,
       ValidIssuer = Configuration["Jwt:Issuer"],
       ValidAudience = Configuration["Jwt:aud"],

   };
});