Пример #1
0
        public static async Task <string> GenerateJwt(ClaimsIdentity identity, IJwtFactory jwtFactory, string userName, JwtIssuerOptions issuerOptions, JsonSerializerSettings serializerSettings)
        {
            var response = new
            {
                id         = identity.Claims.Single(c => c.Type == "id").Value,
                auth_token = await jwtFactory.CreateEncodedToken(userName, identity),
                expires_in = (int)issuerOptions.ValidFor.TotalSeconds
            };

            return(JsonConvert.SerializeObject(response, serializerSettings));
        }