redeem all the WUF (free episodes every 3, 24 and 72 hours),
but i'm having trouble with the login, could you help @Squidy?
here is what i have so far in login, i'm using Playwright
and i do get a token back, but i'm not logged into the site just by using this token, also i also get a token if my login is invalid
Code: Select all
public static async Task LoginAsync(IPage page, IBrowserContext context, Credentials credentials)
{
Console.WriteLine("Logging in...");
// Check if the session cookie already exists
var cookies = await context.CookiesAsync();
var sessionCookie = cookies.FirstOrDefault(cookie => cookie.Name == "JSESSIONID");
if (sessionCookie != null)
{
// Validate the session token
if (await IsSessionValidAsync(context))
{
Console.WriteLine("Already logged in. Session is valid.");
return;
}
else
{
Console.WriteLine("Session is invalid. Proceeding with login...");
}
}
// Prepare login data
var domain = "tapas.io";
var endpoint = $"https://{domain}/account/authenticate";
var postData = new Dictionary<string, string>
{
{ "from", $"https://{domain}/" },
{ "email", credentials.Email }, // Replace with your email
{ "password", credentials.Password }, // Replace with your password
{ "offsetTime", "0" }
};
// Send POST request for authentication
var response = await page.APIRequest.PostAsync(endpoint, new()
{
DataObject = postData
});
// Check if the response contains the session cookie
var responseCookies = await context.CookiesAsync();
sessionCookie = responseCookies.FirstOrDefault(cookie => cookie.Name == "JSESSIONID");
if (sessionCookie is null)
{
Console.WriteLine("Login failed. Unable to retrieve session cookie.");
throw new Exception("Login failed.");
}
// Set cookies globally
await context.AddCookiesAsync(responseCookies.Select(ConvertPlaywriteToNormalCookie));
Console.WriteLine("Login successful. Session cookie set.");
}