static void Main(string[] args) { string keyDir = AppDomain.CurrentDomain.BaseDirectory; if (RSAUtils.TryGetKeyParameters(keyDir, true, out RSAParameters keyParams) == false) { Console.WriteLine("按任意键开始生产RSAKey文件。"); Console.Read(); keyParams = RSAUtils.GenerateAndSaveKey(keyDir); Console.WriteLine("RSAKey文件生存成功!"); } else { //Console.WriteLine("RSAKey文件已经存在!"); Console.WriteLine("生成jwtToken"); JwtTokenUtils jwtTokenUtils = new JwtTokenUtils(); string jwtToken = jwtTokenUtils.GenerateJwtToken("zhuqp", "", "pbirs"); Console.WriteLine(jwtToken); Console.WriteLine("验证jwtToken"); string username = jwtTokenUtils.ValidateJwtToken(jwtToken, "pbirs"); Console.WriteLine(username); Console.Read(); } }
public string GetPowerBIUrl(string userName, string pbiName) { string url = ConfigurationManager.AppSettings["PBIReportsUrl"]; string audience = ConfigurationManager.AppSettings["PBIAudience"]; JwtTokenUtils jwtTokenUtils = new JwtTokenUtils(); string token = jwtTokenUtils.GenerateJwtToken(userName, "", audience); return(url + pbiName + "?rs:embed=true&token=" + token); }