Tag: firebase authentication

在c#.net中验证Firebase JWT

我正在尝试验证一个由firebase android客户端获得的json Web令牌,并将其传递给运行.net的服务器 在这里的答案之后,我创建了这些方法来验证令牌并提取uid: public static async Task<string> GetUserNameFromTokenIfValid(string jsonWebToken) { const string FirebaseProjectId = "testapp-16ecd"; try { // 1. Get Google signing keys HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://www.googleapis.com/robot/v1/metadata/"); HttpResponseMessage response = await client.GetAsync("x509/securetoken@system.gserviceaccount.com"); if (!response.IsSuccessStatusCode) { return null; } var x509Data = await response.Content.ReadAsAsync<Dictionary<string, string>>(); SecurityKey[] keys = x509Data.Values.Select(CreateSecurityKeyFromPublicKey).ToArray(); // […]