protected async Task AddAuthenticationHeaderAsync(CancellationToken cancellationToken, WebhookConfig config, WebHookHeaders webHookHeaders)
        {
            if (config.AuthenticationConfig.Type != AuthenticationType.None)
            {
                var acquireTokenHandler = await _authenticationHandlerFactory.GetAsync(config, cancellationToken);

                var result = await acquireTokenHandler.GetTokenAsync(cancellationToken);

                webHookHeaders.AddRequestHeader(Constants.Headers.Authorization, result);
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public WebHookHeaders GetHttpHeaders(WebhookConfig webhookConfig, MessageData messageData)
        {
            if (webhookConfig == null)
            {
                throw new ArgumentNullException(nameof(webhookConfig));
            }
            if (messageData == null)
            {
                throw new ArgumentNullException(nameof(messageData));
            }

            var headers = new WebHookHeaders();

            headers.AddContentHeader(Constants.Headers.ContentType, webhookConfig.ContentType);
            headers.AddRequestHeader(Constants.Headers.CorrelationId, messageData.CorrelationId);
            headers.AddRequestHeader(Constants.Headers.EventDeliveryId, messageData.CorrelationId);
            headers.AddRequestHeader(Constants.Headers.EventType, webhookConfig.EventType);

            return(headers);
        }