Beispiel #1
0
        public string GenerateToken(TokenClaims claims)
        {
            var handler = new JwtSecurityTokenHandler();

            var creds           = new SigningCredentials(Key, SecurityAlgorithms.HmacSha256);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Issuer             = Issuer,
                Audience           = Issuer,
                Subject            = new ClaimsIdentity(claims.ToClaims()),
                SigningCredentials = creds,
            };

            var token = handler.CreateToken(tokenDescriptor);

            return(handler.WriteToken(token));
        }