diff --git a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs index 337fb55b1..41007f688 100644 --- a/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs +++ b/src/Ocelot/Authentication/Middleware/AuthenticationMiddleware.cs @@ -29,7 +29,7 @@ public async Task Invoke(HttpContext httpContext) $"{httpContext.Request.Path} is an authenticated route. {MiddlewareName} checking if client is authenticated"); var token = httpContext.Request.Headers - .First(r => r.Key.Equals("Authorization", StringComparison.OrdinalIgnoreCase)); + .FirstOrDefault(r => r.Key.Equals("Authorization", StringComparison.OrdinalIgnoreCase)); var cacheKey = $"identityToken.{token}";