27 lines
815 B
C#
27 lines
815 B
C#
using Bibblan.Models;
|
|
using Microsoft.Extensions.Options;
|
|
using System.Net.Http.Headers;
|
|
|
|
namespace Bibblan.Business.Clients
|
|
{
|
|
public class HardcoverAuthenticationHandler : DelegatingHandler
|
|
{
|
|
public BibblanOptions settings;
|
|
|
|
public HardcoverAuthenticationHandler(IOptions<BibblanOptions> options) : base()
|
|
{
|
|
settings = options.Value;
|
|
InnerHandler = new HttpClientHandler();
|
|
}
|
|
|
|
protected override async Task<HttpResponseMessage> SendAsync(
|
|
HttpRequestMessage request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", settings.HardcoverApiToken);
|
|
|
|
return await base.SendAsync(request, cancellationToken);
|
|
}
|
|
}
|
|
}
|