标签:sig ams uil aaaaaa ret div .com yii die
网上似乎没有相关代码
贴上一段Token的解析认证
[TestMethod] public void TestMethod1() { string Token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJMb2dpblR5cGUiOiLlvq7kv6HnmbvlvZUiLCJJc09uZSI6IkZhbHNlIiwiSUQiOiIxMDc2NDYyODY4OTQzMjEyNTQzIiwiUGhvbmUiOiIxMSIsIkVtYWlsIjoiMzMyMSIsIk9wZW5pZCI6IkJCIiwiTmFtZSI6IjEyMyIsIm5iZiI6MTU0Njc1MDQxOSwiZXhwIjoxNTQ2NzUyMjE5LCJpc3MiOiJUZXN0SXNzdWVyIiwiYXVkIjoiVGVzdEF1ZGllbmNlIn0._g3rfr2P3YEFRgKlxv_7DtnxkLq4CrfXBdEUHUDl9jc"; /// 密匙 string IssuerSigningKey = "AAAAAAAAAAAAAAAABBBBBBBBBVCCCCC=="; /// 发行 string ValidIssuer = "TestIssuer"; /// 观众 string ValidAudience = "TestAudience"; var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(IssuerSigningKey)); var tokenValidationParams = new TokenValidationParameters() { ValidateLifetime = true, ValidateAudience = true, ValidateIssuer = true, ValidateIssuerSigningKey = true, ValidIssuer = ValidIssuer, ValidAudience= ValidAudience, IssuerSigningKey = secretKey, }; var jwtTokenHandler = new JwtSecurityTokenHandler(); var a = jwtTokenHandler.ValidateToken(Token, tokenValidationParams, out SecurityToken validated); }
效果:
标签:sig ams uil aaaaaa ret div .com yii die
原文地址:https://www.cnblogs.com/AnAng/p/10228394.html