Create authenticator
This commit is contained in:
parent
5cf09f3f55
commit
e6007489fe
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using RestSharp;
|
||||
using RestSharp.Authenticators;
|
||||
|
||||
namespace HabitSharp {
|
||||
public class HabiticaAuthenticator : IAuthenticator
|
||||
{
|
||||
private readonly Guid userId;
|
||||
private readonly Guid apiKey;
|
||||
|
||||
public HabiticaAuthenticator(Guid userId, Guid apiKey) {
|
||||
this.userId = userId;
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public void Authenticate(IRestClient client, IRestRequest request)
|
||||
{
|
||||
request.AddHeader("X-API-User", userId.ToString());
|
||||
request.AddHeader("X-API-Key", apiKey.ToString());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue