public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            if (!_settings.TokenEndpoint.Enabled)
            {
                Logger.Warn("Endpoint is disabled. Aborting");
                return(NotFound());
            }

            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(this.TokenErrorResponse(result.Error));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }
        public async Task <IHttpActionResult> ProcessAsync(NameValueCollection parameters)
        {
            _logger.Start("OIDC token endpoint.");

            // validate client credentials and client
            var client = await _clientValidator.ValidateClientAsync(parameters, Request.Headers.Authorization);

            if (client == null)
            {
                return(this.TokenErrorResponse(Constants.TokenErrors.InvalidClient));
            }

            // validate the token request
            var result = await _requestValidator.ValidateRequestAsync(parameters, client);

            if (result.IsError)
            {
                return(this.TokenErrorResponse(result.Error));
            }

            // return response
            var response = await _generator.ProcessAsync(_requestValidator.ValidatedRequest);

            return(this.TokenResponse(response));
        }