private string GetApiKeyMessage() { var apiKey = Request.Headers[KeyAuthOptions.DefaultHeaderName]; if (string.IsNullOrEmpty(apiKey)) { throw new InvalidOperationException("Api Key is null"); } var apiKeyName = _apiKeyService.GetKeyName(apiKey); if (string.IsNullOrEmpty(apiKeyName)) { throw new InvalidOperationException("Api key name does not exists for such key"); } return($"API key '{apiKeyName}' is used"); }