public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { HttpRequestMessage request = context.Request; string token = string.Empty; bool existTokenKey = request.Headers.Any(z => z.Key.Equals("Token")); if (existTokenKey) { token = request.Headers.FirstOrDefault(z => z.Key.Equals("Token")).Value.First(); } if (string.IsNullOrEmpty(token)) { context.ErrorResult = new AuthenticationFailureResult("Token Required", request); return; } AuthenticationBusiness authenticationFactory = new AuthenticationBusiness(); SessionEntity session = authenticationFactory.ApplicationSessionCheck(token); if (session == null || session.ApplicationID == 0) { context.ErrorResult = new AuthenticationFailureResult("Token Not Found Or Expired", request); return; } context.Request.Properties.Add(CommonConstants.SessionName, session); }