stale-dress-83211
07/10/2024, 10:57 AMdazzling-napkin-4938
07/11/2024, 5:49 AMglamorous-rose-76256
07/11/2024, 1:15 PMoauth2/auth
for the exchange code and oauth2/token
for the access token. There is some setup to do on the Ory Project, such as creating a OAuth Client.stale-dress-83211
07/15/2024, 9:54 AMstale-dress-83211
07/15/2024, 11:31 AMUnityWebRequest request = UnityWebRequest.Get("'ory-http/self-service/registration/api");
yield return request.SendWebRequest();
FlowResponse flowResponse = JsonUtility.FromJson<FlowResponse>(request.downloadHandler.text); // Flowresponse contains just 'id' field
But I'm somehow getting an error response from registering user. It says "...Could not find a strategy to sign you up with. Did you fill out the form correctly?"
This is my code:
string completeRegistrationUrl = $"{ory-http/self-service/registration?flow={flowId}";
RegistrationRequest requestObject = new RegistrationRequest
{
traits = new Traits
{
email = email,
username = "name",
},
password = password
};
string jsonBody = JsonUtility.ToJson(requestObject);
Debug.Log($"Registration JSON: {jsonBody}");
UnityWebRequest request = new UnityWebRequest(completeRegistrationUrl, "POST");
byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonBody);
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
yield return request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
{
Debug.LogError($"Error sending request: {request.error}");
Debug.LogError($"Response code: {request.responseCode}");
Debug.LogError($"Response: {request.downloadHandler.text}");
yield break;
}
Any ideas?stale-dress-83211
07/15/2024, 3:01 PM{
"error": {
"id": "security_csrf_violation",
"code": 403,
"status": "Forbidden",
"request": "134a2d69-553a-9bb0-9baa-68b55707c866",
"reason": "Please retry the flow and optionally clear your cookies. The request was rejected to protect you from Cross-Site-Request-Forgery (CSRF) which could cause account takeover, leaking personal information, and other serious security issues.",
"details": {
"docs": "<https://www.ory.sh/kratos/docs/debug/csrf>",
"hint": "The anti-CSRF cookie was found but the CSRF token was not included in the HTTP request body (csrf_token) nor in the HTTP Header (X-CSRF-Token).",
"reject_reason": "The HTTP Cookie Header was set and a CSRF token was sent but they do not match. We recommend deleting all cookies for this domain and retrying the flow."
},
"message": "the request was rejected to protect you from Cross-Site-Request-Forgery"
}
}
dazzling-napkin-4938
07/15/2024, 11:54 PMcsrf_token
field to the submission?stale-dress-83211
07/16/2024, 7:12 AMdazzling-napkin-4938
07/16/2024, 11:44 PMcsrf_token
being blank in the form is normal for native flows. You’d need to inspect the requests between you and kratos I think, or maybe someone from the Ory team might understand what’s going on betterstale-dress-83211
07/17/2024, 9:57 AMdazzling-napkin-4938
07/18/2024, 12:43 AM