Add project files.

This commit is contained in:
Sergio Matias Urquin
2025-04-29 18:56:29 -06:00
parent ad652bc070
commit 7d760b589e
91 changed files with 4366 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
// ***********************************************************************
// <copyright file="AuthenticatedHttpClientHandler.cs">
// Heath
// </copyright>
// ***********************************************************************
namespace Core.Cerberos.External.Helpers.Token
{
/// <summary>
/// Class to inject the token in all requests.
/// </summary>
public class AuthenticatedHttpClientHandler : DelegatingHandler
{
private readonly ITokenProvider _tokenProvider;
public AuthenticatedHttpClientHandler(ITokenProvider tokenProvider)
{
_tokenProvider = tokenProvider;
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var token = _tokenProvider.GetToken();
if (!string.IsNullOrEmpty(token))
{
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
}
return await base.SendAsync(request, cancellationToken);
}
}
}