public async Task Invoke(HttpContext context)
 {
     var handler = new ClaimsTransformationHandler(Options.Transformer, context);
     handler.RegisterAuthenticationHandler(context.GetAuthentication());
     try
     {
         if (Options.Transformer != null)
         {
             var transformationContext = new ClaimsTransformationContext(context)
             {
                 Principal = context.User
             };
             context.User = await Options.Transformer.TransformAsync(transformationContext);
         }
         await _next(context);
     }
     finally
     {
         handler.UnregisterAuthenticationHandler(context.GetAuthentication());
     }
 }
        public async Task Invoke(HttpContext context)
        {
            var handler = new ClaimsTransformationHandler(Options.Transformer, context);

            handler.RegisterAuthenticationHandler(context.GetAuthentication());
            try
            {
                if (Options.Transformer != null)
                {
                    var transformationContext = new ClaimsTransformationContext(context)
                    {
                        Principal = context.User
                    };
                    context.User = await Options.Transformer.TransformAsync(transformationContext);
                }
                await _next(context);
            }
            finally
            {
                handler.UnregisterAuthenticationHandler(context.GetAuthentication());
            }
        }