Spotify.NET/SpotifyAPI.Web/Authenticators/TokenAuthenticator.cs

27 lines
588 B
C#
Raw Normal View History

2020-05-01 19:05:28 +01:00
using System.Threading.Tasks;
2020-06-03 16:44:13 +01:00
using SpotifyAPI.Web.Http;
2020-05-01 19:05:28 +01:00
2020-06-03 16:44:13 +01:00
namespace SpotifyAPI.Web
2020-05-01 19:05:28 +01:00
{
public class TokenAuthenticator : IAuthenticator
2020-05-01 19:05:28 +01:00
{
public TokenAuthenticator(string token, string tokenType)
2020-05-01 19:05:28 +01:00
{
Token = token;
TokenType = tokenType;
}
public string Token { get; set; }
public string TokenType { get; set; }
public Task Apply(IRequest request, IAPIConnector apiConnector)
2020-05-01 19:05:28 +01:00
{
Ensure.ArgumentNotNull(request, nameof(request));
2020-05-01 19:05:28 +01:00
request.Headers["Authorization"] = $"{TokenType} {Token}";
return Task.CompletedTask;
}
}
}