Does anyone know why my call to `updateLoginFlow` ...
# talk-kratos
m
Does anyone know why my call to
updateLoginFlow
is returning a 422? I'm calling it from the SDK like so, inside my SPA:
Copy code
ory.createBrowserLoginFlow().then(({ data: flow }) => {
  const flowId = flow.id;
  ory
    .updateLoginFlow({ flow: flowId, updateLoginFlowBody: { method: 'oidc', provider: 'my-okta-test' } })
    .then(({ data: successRes }) => { ... })
})
but the
.updateLoginFlow
call is returning a 422. Here is the curl output of that call, which I got from my browser's networking tab:
And here's a relevant excerpt from my config:
I tried looking at the code for where this
browser_location_change_required
error was thrown, and this section might be relevant: https://github.com/ory/kratos/blob/7c0e02efdc115b5ac9dcf7e6517a27e903c02643/selfservice/strategy/oidc/strategy_login.go#L280-L284 Are JSON requests are not supported? Or maybe I'm not correctly configuring my call to
updateLoginFlow
? Any help is appreciated!
When I observe a call to the
/self-service/login
endpoint from the
kratos-selfservice-ui-node
app (which is server-side), the call succeeds and returns a 302 as expected. Here is the curl from that request. Why is this request succeeding, but my request failing?
l
That’s the expected success response from a request from a SPA
Copy code
browser_location_change_required: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.
The response body will contain a
redirect_browser_to
value and you need to handle the redirect yourself. More info here: https://www.ory.sh/docs/reference/api#tag/frontend/operation/updateLoginFlow
m
Thanks for the insight! Yeah, I can workaround this by catching the 422 and redirecting from there. I see now that the example SPA app is catching the 422 as well: https://github.com/ory/elements/blob/87f0f2478687700837b8e0fa1a28e5d64c5fb57a/examples/react-spa/src/sdk.ts#L120-L164 Catching a 422 as part of a normal workflow feels odd, I wonder if they're gonna change that... But I'm unblocked for now. Thanks again!