-
Hi, thanks for this great repository. I am building a react SPA which uses Ory Kratos for login and registration, using both the password and OIDC (google) methods. On the front end I am using the Ory kratos-client JS SDK. I have successfully setup the login flow for both OIDC and password methods, but whenever I attempt to submit the registration flow, the Kratos server gives:
and
On the react SPA it says: Headers in example registration request:
My config file:
Ory Kratos is running on docker compose and the service version (despite what the config file says) is v0.8.0-alpha.3 It is mentioned at various places in the docs and in the discussion that AJAX registration is not supported, but it also mentioned that this was to be fixed by version 0.6. I also took a look at the CORS guide in the docs but it does not seem to have resolved the issue. Just wondering if anyone could give me a pointer in the right direction. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You are making a request with the HTTP method "PASSWORD", but that is not correct. It should be a "POST" request. Consider using the official SDKs! |
Beta Was this translation helpful? Give feedback.
-
I have discovered the cause of the problem. I mistakenly believed that the parameters on the submitSelfServiceRegistration method in the Ory/kratos-client JS SDK were the same as the submitSelfServiceLogin method. As you can see, the submitSelfServiceLogin has an optional second parameter (xSessionToken) that registration does not have:
I successfully used this API call to login: However, because the registration flow does not have the second argument, the body object which contained the registration body was instead passed as the options parameter. The registration body included a field called "method" to distinguish between 'oidc' and 'password' but because it was passed as an option to Axios, Axios interpreted it as the HTTP method, thus giving the CORS error. The correct api call in this case is: |
Beta Was this translation helpful? Give feedback.
I have discovered the cause of the problem. I mistakenly believed that the parameters on the submitSelfServiceRegistration method in the Ory/kratos-client JS SDK were the same as the submitSelfServiceLogin method. As you can see, the submitSelfServiceLogin has an optional second parameter (xSessionToken) that registration does not have:
async submitSelfServiceLoginFlow(flow: string, xSessionToken?: string, submitSelfServiceLoginFlowBody?: SubmitSelfServiceLoginFlowBody, options?: any)
async submitSelfServiceRegistrationFlow(flow: string, submitSelfServiceRegistrationFlowBody?: SubmitSelfServiceRegistrationFlowBody, options?: any)
I successfully used this API call to login:
submitSelfServi…