Files
Wino-Mail/Wino.Core/Http/MicrosoftTokenProvider.cs

34 lines
1.1 KiB
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Kiota.Abstractions.Authentication;
using Wino.Core.Domain.Entities.Shared;
2024-04-18 01:44:37 +02:00
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.Http
{
public class MicrosoftTokenProvider : IAccessTokenProvider
{
private readonly MailAccount _account;
private readonly IAuthenticator _authenticator;
public MicrosoftTokenProvider(MailAccount account, IAuthenticator authenticator)
{
_account = account;
_authenticator = authenticator;
}
public AllowedHostsValidator AllowedHostsValidator { get; }
public async Task<string> GetAuthorizationTokenAsync(Uri uri,
Dictionary<string, object> additionalAuthenticationContext = null,
CancellationToken cancellationToken = default)
2024-04-18 01:44:37 +02:00
{
var tokenInfo = await _authenticator.GetTokenInformationAsync(_account);
2024-04-18 01:44:37 +02:00
return tokenInfo.AccessToken;
2024-04-18 01:44:37 +02:00
}
}
}