I had reproduced a library to verify firebase token base on this respo. My app uses the azure function like a backend, so after the user logged in, every action will send to the azure function with the token, and the azure function will validate that token then respond to the results. The library takes the public key from here. I had created an azure function to test this library. My request:
var client = new RestClient("http://localhost:7071/api/test-connection");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("x-requested-with", "XMLHttpRequest");
request.AddHeader("Authorization", "Bearer <My Firebase Token>");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
I encountered an exception
IDX10516: Signature validation failed. Unable to match key:
kid: 'System.String'.
Exceptions caught:
'System.Text.StringBuilder'.
token: 'System.IdentityModel.Tokens.Jwt.JwtSecurityToken'. Valid Lifetime: 'System.Boolean'. Valid Issuer: 'System.Boolean'
I had spent over 2 days researching the reasons and solutions. A week before my code worked well. Is the problem caused by the public keys I got from google?