blue-alarm-98979
04/04/2024, 11:07 AMConfiguration config = new Configuration();
config.BasePath = "<http://127.0.0.1:4433/>";
var frontendApi = new FrontendApi(config);
var cookieHeader = ctx.Request.Headers["cookie"];
var loginflow = frontendApi.CreateBrowserLoginFlow(cookie: cookieHeader);
var flowId = loginflow.Id;
// Find the CSRF token
string csrfToken = null;
foreach (var node in loginflow.Ui.Nodes)
{
if (node.Attributes.ActualInstance is KratosUiNodeInputAttributes inputAttributes)
{
if (inputAttributes.Name == "csrf_token")
{
csrfToken = inputAttributes.Value.ToString();
break;
}
}
}
if (csrfToken == null)
{
throw new Exception("CSRF token not found in login flow");
}
KratosUpdateLoginFlowWithPasswordMethod method = new(csrfToken, request.Email, "password", request.Password);
var updateLoginFlowBody = new KratosUpdateLoginFlowBody(method);
var result = frontendApi.UpdateLoginFlow(flowId, updateLoginFlowBody, cookie: cookieHeader);
var session = result.Session;"
.. any ideas where should be the problem?? I double checked and compared if token and flowId values are the same and yes, they are.. I will be thankful for any helpmagnificent-energy-493
cookie
parameter of the CreateBrowserLoginFlow
and UpdateLoginFlow
methods. Make sure that this cookie is being sent correctly.
3. Clear your cookies: The error message suggests clearing all cookies for the domain and retrying the flow. This could help if there's an old or invalid CSRF cookie that's causing the issue.
4. Check for issues with your environment or setup: There could be issues with your environment or setup that are causing the CSRF check to fail. For example, if you're running your application behind a proxy, the proxy could be stripping or modifying the CSRF cookie or token.