lucidiot/HabitSharp
lucidiot
/
HabitSharp
Archived
1
0
Fork 0

Create authenticator

This commit is contained in:
Lucidiot 2018-08-31 00:42:16 +02:00
parent 5cf09f3f55
commit e6007489fe
No known key found for this signature in database
GPG Key ID: AE3F7205692FA205
1 changed files with 22 additions and 0 deletions

22
HabiticaAuthenticator.cs Normal file
View File

@ -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());
}
}
}