test av integration mot hardcover
This commit is contained in:
26
Server/Business/Clients/HardcoverAuthenticationHandler.cs
Normal file
26
Server/Business/Clients/HardcoverAuthenticationHandler.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user