initial commit

This commit is contained in:
Arne Moerman
2024-12-15 19:04:29 +01:00
commit ea58deab8c
15 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using System.Net.Http.Headers;
namespace LetterBoxdUnwatchedGenerator
{
public class LetterBoxdConnection
{
const string baseUrl = "https://letterboxd.com/api/v0/";
HttpClient httpClient;
public LetterBoxdConnection()
{
//Authentication
httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
//add url form encoded content
var results = httpClient.PostAsync(baseUrl + "auth/token", new StringContent("grant_type=password&username=USERNAME&password=PASSWORD", MediaTypeHeaderValue.Parse("application/x-www-form-urlencoded"))); //, Encoding.UTF8, "application/x-www-form-urlencoded"));
results.Result.EnsureSuccessStatusCode();
var bearer = results.Result.Content.ReadAsStringAsync().Result;
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bearer);
}
}
}