2020-05-01 19:05:28 +01:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
namespace SpotifyAPI.Web.Http
|
|
|
|
{
|
2020-05-02 12:04:26 +01:00
|
|
|
public class TokenHeaderAuthenticator : IAuthenticator
|
2020-05-01 19:05:28 +01:00
|
|
|
{
|
|
|
|
public TokenHeaderAuthenticator(string token, string tokenType)
|
|
|
|
{
|
|
|
|
Token = token;
|
|
|
|
TokenType = tokenType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Token { get; set; }
|
|
|
|
|
|
|
|
public string TokenType { get; set; }
|
|
|
|
|
|
|
|
public Task Apply(IRequest request)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|