2020-05-01 19:05:28 +01:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web.Http
|
|
|
|
{
|
2020-05-13 22:49:54 +01:00
|
|
|
public class TokenAuthenticator : IAuthenticator
|
2020-05-01 19:05:28 +01:00
|
|
|
{
|
2020-05-13 22:49:54 +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; }
|
|
|
|
|
2020-05-13 22:49:54 +01:00
|
|
|
public Task Apply(IRequest request, IAPIConnector apiConnector)
|
2020-05-01 19:05:28 +01:00
|
|
|
{
|
2020-05-05 14:30:00 +01:00
|
|
|
Ensure.ArgumentNotNull(request, nameof(request));
|
|
|
|
|
2020-05-01 19:05:28 +01:00
|
|
|
request.Headers["Authorization"] = $"{TokenType} {Token}";
|
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|