public async Task Invoke(IDictionary <string, object> environment)
        {
            var headers = environment["owin.RequestHeaders"] as IDictionary <string, string[]>;

            Debug.Assert(headers != null, "headers != null");
            if (headers.ContainsKey("Authorization") && headers["Authorization"][0] == "Bearer SomeValidAuthToken")
            {
                headers["Authorization"][0] = $"Bearer {_tokenGenerator.Generate()}";
            }

            await _next.Invoke(environment);
        }
        public async Task Invoke(IDictionary <string, object> environment)
        {
            IOwinContext context = new OwinContext(environment);

            if (context.Request.Headers != null &&
                context.Request.Headers.ContainsKey(AuthorizationKey) &&
                context.Request.Headers[AuthorizationKey] == "Bearer SomeValidAuthToken")
            {
                context.Request.Headers[AuthorizationKey] = $"Bearer {_tokenGenerator.Generate()}";
            }

            await _next.Invoke(context.Environment);
        }