net core 接收token,并解析token获取信息
[HttpGet] public void Info() { //获取到token var token = HttpContext.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last(); //解析token信息 var handler = new JwtSecurityTokenHandler(); var jwtToken = handler.ReadJwtToken(token); // 打印JWT的Payload中的Claims foreach (var claim in jwtToken.Payload.Claims) { Console.WriteLine($"Claim: {claim.Type} - Value: {claim.Value}"); } }