public string GetEncryptedToken(string audience, string credentials) { JsonWebEncryptedToken token = new JsonWebEncryptedToken() { AsymmetricKey = audienceKeys[audience], Issuer = "TokenIssuer", Audience = audience }; token.AddClaim(ClaimTypes.Name, credentials); return(token.ToString()); }
public void AuthenticateWithEncryptedToken(string token) { JsonWebEncryptedToken jwt = null; try { jwt = JsonWebEncryptedToken.Parse(token, this.secretKey); Thread.CurrentPrincipal = new ClaimsPrincipal(new ClaimsIdentity(jwt.Claims, "JWT")); } catch (Exception ex) { Console.WriteLine(ex.Message); } }