Spotify.NET/SpotifyAPI.Web/Http/Authenticators/TokenAuthenticator.cs
2020-05-13 23:49:54 +02:00

26 lines
566 B
C#

using System.Threading.Tasks;
namespace SpotifyAPI.Web.Http
{
public class TokenAuthenticator : IAuthenticator
{
public TokenAuthenticator(string token, string tokenType)
{
Token = token;
TokenType = tokenType;
}
public string Token { get; set; }
public string TokenType { get; set; }
public Task Apply(IRequest request, IAPIConnector apiConnector)
{
Ensure.ArgumentNotNull(request, nameof(request));
request.Headers["Authorization"] = $"{TokenType} {Token}";
return Task.CompletedTask;
}
}
}